Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="alert alert-info" id="1">
- <p><b><span class="adName">Name</span></b><br>
- <span class="ad1">address1</span><br>
- <span class="ad2">address2</span><br>
- <span class="ad3">address3</span><br>
- <span class="adCity">city</span><br>
- <span class="adState">state</span><br>
- <span class="adPin">pincode</span><br>
- Ph no :<span class="adPhone">phone</span><br>
- </p>
- </div
- $('.alert.alert-info').click(function(){
- var $this = $(this);
- adName = $this.find('.adName').text();
- ad2 = $this.find('.ad2').text();
- //So you can repeat for remaining elements.
- });
- $('.alert-info').click(function(){
- var $spans = $(this).find('span');
- // Loop through all the spans inside this div
- $spans.each(function(){
- alert($(this).text());
- })
- });
- $('.alert-info').click(function(){
- alert($(this));//This will give you the clicked DIV object
- $(this).find('span'); //This will give you all spans inside it
- });
- $('div.alert-info').click(function(){
- var id =$(this).attr("id");
- var name = $('#' +id").children("span").text();
- });
- $('.alert alert-info').click(function()
- {
- var name = $(this).find('span.adName').html();
- var city = $(this).find('span.adCity').html();
- // likewise you can get content of all the span under the div which you have clicked
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement