Javascript examples for jQuery:Tag Traversing
Jquery refer to initial element selector
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> <script type="text/javascript"> $(function(){/* w w w . ja v a 2s . c o m*/ $('.someclass').each(function(){ $(this).next('span').append('<input class="textbox" name="'+$(this).attr("name")+'-x'+'"/>'); }) }); </script> </head> <body> <span class="someclass"></span> <span></span> </body> </html>