Add div id dynamically in jquery

Try this: $(“li”).each(function(i, e) { $(e).attr(“id”, “_id” + i); }); You can, for instance, use randomized stream of characters to impersonate IDs. Maybe this is what you’re intending to do. It’s tough to figure out what you want from such a short description. However, I hope it helps.

How do I hide the tooltip ‘title’ when using a lightbox plugin

If you want to stick with this plugin, your have to change its code a little. Modifying jquery.lightbox-0.5.js, change // in line 77: objClicked.getAttribute(‘title’) // replace by: objClicked.getAttribute(‘data-lightboxtitle’) and // in line 81: jQueryMatchedObj[i].getAttribute(‘title’) // replace by: jQueryMatchedObj[i].getAttribute(‘data-lightboxtitle’) Then in your HTML, just replace the title attributes in your a with the data-lightboxtitle, like so … Read more

How to change the element of another div by clicking and hovering on an element of a different div

Like people have said there are many ways to do this. One way would be to use JavaScript event listeners. Here’s a quick little demo: let change = document.getElementById(“change”); let hover = document.getElementById(“hover”); hover.addEventListener(“mouseover”, changeColor); hover.addEventListener(“mouseout”, changeColor); function changeColor() { change.classList.toggle(“red”); } div { width: 100px; height: 100px; margin: 2rem; background-color: green; } .red { … Read more

meaning of console.log(id); id = id.split(" "); [closed]

console.log writes the value to the JavaScript Console. id.split(” “) splits the string id at the space into an array. var id = “This is a string”; var idParts = id.split(” “); for(var i = 0; i < idParts.length; i++) { console.log(idParts[i]); } The above will output “This”, “is”, “a”, and “string” to the javascript … Read more

Can't able to apply css file in html5

Here is your issue. <link rel = “stylesheet” type = “text/css” href = “https://stackoverflow.com/questions/26623523/css/style.css” /> There should be no spaces between attr and its value: <link rel=”stylesheet” type=”text/css” href=”https://stackoverflow.com/questions/26623523/css/style.css” />

jQuery Adding new option to select element doesn't pick up the string [closed]

Change: var str = $(‘#country-select’).val() + ” ” + $(“#” + $(“#country-select option:selected”).val() + “-select option:selected”).val(); to: var str = $(‘#country-select, .sub-menu’).val() + ” ” + $(“#” + $(“#country-select option:selected”).val() + “-select option:selected”).val(); jFiddle example You need to trigger the change on both the first and second selects, so $(‘#country-select, .sub-menu’) is needed.