javascript - Check to see if a div exists -
i have following code:
<html> <head> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body> <span></span> <div class="content" id="2"> <div class="reply"></div> </div> <div class="content" id="1"> </div> <div class="content" id="3"> <div class"reply"></div> </div> <script> var n = $( ".reply" ).length; $( "span" ).text( "there " + n + " divs."); </script> </body> </html>
i trying write jquery script check individual divs unique id's see if contains "reply" div. have code see if "reply" div exists @ working. new jquery unsure how go this.
var n = $( ".reply" ).length; $( "span" ).text( "there " + n + " divs.");
use #uniqueid .reply
jquery selector:
alert("the id id '3' contains" + $("#3 .reply").length + ".reply divs.");
Comments
Post a Comment