[ACCEPTED]-jquery find next element with class-next
Accepted answer
The problem is that your using the next 4 traversing function rather than nextAll
$("button[disabled]").nextAll(".error").text("this button is disabled");
When you 3 use next its just looking at the "next" element 2 which is
<span>no overwrite</span>
Next all looks at all siblings 1 that are next
Try this:
$("button[disabled=disabled]").parent().find("span.error").text("this button is disabled");
hope it helps. Sinan.
0
next()
won't work in this case because it has 2 to be a sibling for that to work. In this 1 case you need:
$("button[disabled]").parent().nextAll()
.find("span.error:first").text("this button is disabled");
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.