Thursday, January 24, 2013

Show Hide the corresponding div

<span class="question" id="1">what is your name?</span>
<div id="ans1">
test</div>
<span class="question" id="2">what is your name?</span>
<div id="ans2">
test</div>
<span class="question" id="3">what is your name?</span>
<div id="ans3">
test</div>
$(document).ready(function()

{
 $(".question").click(function()
 {
  id= $(this)attr('id');
  $("#ans"+id).slideToggle();
 }

 )
 }

);

Bind Some Event to Element and trigger that function when click the element

Scenario: Suppose if we used same click event function in various web pages. if you want do some logic some page button for that need to re...