Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <div class="alert alert-info" id="1">
  2. <p><b><span class="adName">Name</span></b><br>
  3. <span class="ad1">address1</span><br>
  4. <span class="ad2">address2</span><br>
  5. <span class="ad3">address3</span><br>
  6. <span class="adCity">city</span><br>
  7. <span class="adState">state</span><br>
  8. <span class="adPin">pincode</span><br>
  9. Ph no :<span class="adPhone">phone</span><br>
  10. </p>
  11. </div
  12.  
  13. $('.alert.alert-info').click(function(){
  14. var $this = $(this);
  15. adName = $this.find('.adName').text();
  16. ad2 = $this.find('.ad2').text();
  17. //So you can repeat for remaining elements.
  18. });
  19.  
  20. $('.alert-info').click(function(){
  21. var $spans = $(this).find('span');
  22.  
  23. // Loop through all the spans inside this div
  24. $spans.each(function(){
  25. alert($(this).text());
  26. })
  27. });
  28.  
  29. $('.alert-info').click(function(){
  30. alert($(this));//This will give you the clicked DIV object
  31. $(this).find('span'); //This will give you all spans inside it
  32. });
  33.  
  34. $('div.alert-info').click(function(){
  35. var id =$(this).attr("id");
  36. var name = $('#' +id").children("span").text();
  37.  
  38. });
  39.  
  40. $('.alert alert-info').click(function()
  41. {
  42. var name = $(this).find('span.adName').html();
  43. var city = $(this).find('span.adCity').html();
  44. // likewise you can get content of all the span under the div which you have clicked
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement