jquery .next() skips selected elements separated by <br> tags -
why doesn't jquery's .next() function return next selected item when items separated <br>
tags?
here's code taken jqueryui website demo area:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>jquery ui button - icons</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <script> $(function() { $( "button:first" ).button({ icons: { primary: "ui-icon-locked" }, text: false }).next().button({ icons: { primary: "ui-icon-locked" } }).next().button({ icons: { primary: "ui-icon-gear", secondary: "ui-icon-triangle-1-s" } }).next().button({ icons: { primary: "ui-icon-gear", secondary: "ui-icon-triangle-1-s" }, text: false }); }); </script> </head> <body> <button>button icon only</button> <button>button icon on left</button> <button>button 2 icons</button> <button>button 2 icons , no text</button> </body> </html>
this results in display like:
but if insert <br>
tag after first element, next .button() call skipped resulting in following display:
the second .next().button( ... "ui-icon-locked" ...) function seems skipped , rest of .next().button() functions off-by-one.
i can fix using ids, creating buttonset , styling , i'm sure there other ways too, there jquery selections , <br>
tags missing here?
.next()
return next element. passing parameter function "condition". if condition isnt met, jquery object empty.
you can use .nextall()
:first
counter this:
$('button:first').button(...).nextall('button:first') //and on , on
Comments
Post a Comment