In the navigation text, my objective is to pick out the final sentence following *
For example;
Home*Development*Mobil and Web Development
I am only interested in selecting the last sentence after * --> (Mobil and Web Development)
In the navigation text, my objective is to pick out the final sentence following *
For example;
Home*Development*Mobil and Web Development
I am only interested in selecting the last sentence after * --> (Mobil and Web Development)
To extract the text Mobil and Web Development
from a given string, you can utilize the method .split(/[*]+/).pop()
.
Example
var result = "Home*Development*Mobil and Web Development".split(/[*]+/).pop();
console.log(result)
To achieve this, you can utilize Regular Expressions in JavaScript
let example = "Home*Development*Mobil and Web Development";
let regexPattern = /.*\*(.*)$/
let results = example.match(regexPattern);
console.log(results[1]);
If you're looking to add some styling specifically to the last part of a sentence, one approach is to utilize JavaScript to target elements with a specific class on page load, extract the final portion, wrap it in a span element, and style it accordingly:
const selectLasts = document.querySelectorAll('.selectLast');
selectLasts.forEach(selectLast => {
const text = selectLast.innerHTML;
const arr = text.split('*');
const lastText = arr.pop();
selectLast.innerHTML = arr.join('*');
const lastEl = document.createElement('span');
lastEl.innerHTML = '*' + lastText;
selectLast.appendChild(lastEl);
});
.selectLast span {
background-color: yellow;
}
<div class="selectLast">Home*Development*Mobil and Web Development</div>
To add a child element within a div, simply nest it inside as shown below and apply CSS styling accordingly.
div > span {
color:blue;
}
<div>
Website "" Designing "" <span>Graphic and UI Design</span>
</div>
How can I create a dropdown box that includes a label of "select so and so..." and when the user clicks on it, a list of options is displayed with the first option being blank instead of showing the label name? Is it possible to include an input box insi ...
I am trying to send array elements from my Java code to a JSP page. The goal is for the array elements to be displayed on the page when a button is clicked. I have attempted to use the JSTL forEach tag within JavaScript or jQuery, but unfortunately, it do ...
Upon inspecting the HTML code generated by jQuery Mobile, I noticed: <input placeholder="Filter Items..." data-type="search" class="ui-input-text ui-body-b"> I tried to modify this value with the following code: $("ul[data-filter='true'] ...
I have a loop that generates random numbers and positions to create 4 answer choices for users. Now, I am trying to determine the value of the clicked button and compare it to the position of the correct answer. However, whenever I try to do this, it retu ...
After observing, the inner-header and inner-footer div scroll along with the area that contains the select list. How can I make that area scroll down while keeping the inner-header/footer fixed within the content? I hope my query is understandable. Thank ...
I attempted to test out the Start Bootstrap Bare template using Node.js and Express. (Link to Start Bootstrap Template) I opted not to make any alterations to the HTML, CSS, and JavaScript files provided with the template. Instead, I created a new index.j ...
Is there a way to use jquery to insert a div after every dd tag in a document? $(document).ready(function(){ $('dd').xyz('<div class="clear"></div>'); // how can we define this xyz function? }); Consider the following ...
Trying to utilize the next/image feature to display an SVG image is causing me some trouble. Every time I attempt this, an error message pops up: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite ...
Every time I click on a table a, intending to toggle the .info inside the same div, it also toggles the .info in other divs. Can someone provide assistance with this issue? function info() { $('.table a').click(function() { $('.info ...
Issue: I have encountered difficulties finding an efficient solution for this. Here's a summary of what I attempted: To start, ensure that allowJs and checkJs are both set to true in the tsconfig.json, then include the project files accordingly. Ty ...
After disabling a button with a click handler, I have noticed an interesting behavior where the button does not submit afterwards. The issue seems to vary between different browsers, with Firefox still allowing form submission after the button is disabled, ...
When attempting to update data using the PUT Method in my angular service and express routes, I encountered a 401 error. Here is my service code: //401 makeAdmin(_id) { this.loadToken() let headers = new Headers() headers.append('Authorization& ...
In a multidimensional array, I am looking to detect and count duplicates. If duplicates are found, an alert should be triggered. Arr =[[2,"sk"],[3,"df"],[7,"uz"],[3,"df"],[7,"gh"]] Suggestions: One way to ...
Currently, I am attempting to utilize jQuery ajax to fetch a project page. In this scenario, the xhr variable is expected to hold the correct string to the webpage (the target page). I have set up a condition to prevent the page from loading as a mobile v ...
Here is an example in Html: <!-- Note 'display-when' is hyphenated --> <wait-cursor display-when="true"></wait-cursor> Then, when defining it in the directive: scope: { // Note 'displayWhen' is camelCased show: ...
Is there a way to detect the browser width dynamically? For instance, can I adjust the CSS styling based on zoom adjustments like ctrl + or ctrl -? By "box," I am referring to a perfectly square shape. So, when the browser width is 100%, I want a layout wi ...
If a user is accessing the site using a PS3, I want them to be redirected to a different webpage Below is the code snippet I have been attempting to use: <script language=javascript> <!-- if ((navigator.userAgent.match(/iMozilla/i)) || (navigato ...
Javascript: <script> $(document).ready(function(){//Implementing AJAX functionality $(".acceptorbutton").on('click', function(){ var whichClicked = this.attr('name'); ...
Having trouble installing a new NestJs project using yarn. Operating system : Microsoft Windows [version 10.0.19044.3086] Node version : 18.17.1 npm version : 9.6.7 yarn version : 1.22.19 Nest cli version : 10.1.16 I attempted to install by running : npm ...
Presented below is an object: { "_id" : ObjectId("5a8d83d5d5048f1c9ae877a8"), "websites" : [ "", "", "" ], "keys" : [ { "_id" : ObjectId("5a8d83d5d5048f1c9ae877af"), "name ...