- This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
Viewing 9 posts - 1 through 9 (of 9 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › jquery effect not working
why my p tag is not toggleing in second div(container2).i put the same p tag and button tag in the second div but why its jquery effect not working as it works perfectly in first div. here is mo code. http://jsfiddle.net/SeEGj/
IDs are supposed to be unique. To make your code work, just use something like this.
$(document).ready(function(){
$("button").click(function(evt){
$('p', evt.target.parentNode).toggle();
});
});
can u plz write a code pen? i would give a better idea.
Here you go, you could have just changed the javascript in your fiddle tho :)
if i use id or class of an element instead of button it did’nt work. how is it done with elements id or class instead of just using direct tag name like button here? i have 5 list items each with an ID when hover over each list item an image slides with it. its working perfectly fine but when i copy pasted this same list in the same page jquery does’nt work and the image dont move.
You cannot expect jQuery to work when using IDs for selectors and have more than one element with the same ID. Provide a live example of the page so we could give you some hints :)
here is my code:
http://jsfiddle.net/xJF6Y/
jquery only works in container div, but same thing is not working in container2 div.
The values of ID attributes are supposed to be unique. This code will work.
http://jsfiddle.net/4GsnM/1/
Please take your time to read this:
http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.2
thanku so much whatsoever. :)