1. Ques: Write a code for get the text value of a selected option?
<select id="ddl">
<option value="1">Employee</option>
<option value="2">Manager</option>
<option value="3">HR</option>
<option value="4">Teacher</option>
</select>
Answer: $("#pcdsselect").val();
2. Ques: Write a code for check or unchecked a checkbox input or radio button?
Answer:
$('#pcds').attr('checked', true);
$('#pcds').attr('checked', false);
3. Ques: How do You disable or enable a form element?
Answer:
// Disable #pcds
$('#pcds').attr('disabled', true);
// Enable #pcds
$('#pcds').attr('disabled', false);
4. Ques: What is the Document Ready Event syntax ?
Answer:
$(document).ready(function(){
});
5. Ques: Write a code for hide method of different selector ?
Answer:
<p id="myherder" class="myherderclass">This is a paragraph Element in html.</p>
$(this).hide() -its hides the current element.
$("p").hide() -its hides all <p> elements.
$(".myherderclass").hide() -its hides all elements with class="myherder".
$("#myherder").hide() - its hides the element with id="myherder".
6. Ques: Explain the code syntax and example of hide() and show() method in Jquery ?
Answer:
Syntax: $(selector).hide(speed,callback);
Ex:
<p id="ParaId">This is a paragraph Element in html.</p>
$("#ParaId").click(function(){
$("p").hide();
});
$("#ParaId").click(function(){
$("p").show();
});
7. Ques: What are the use of jQuery toggle() method ?
Answer:
toggle() method just toggle between the hide() and show() methods in jQuery ?
Ex:
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
<select id="ddl">
<option value="1">Employee</option>
<option value="2">Manager</option>
<option value="3">HR</option>
<option value="4">Teacher</option>
</select>
Answer: $("#pcdsselect").val();
2. Ques: Write a code for check or unchecked a checkbox input or radio button?
Answer:
$('#pcds').attr('checked', true);
$('#pcds').attr('checked', false);
3. Ques: How do You disable or enable a form element?
Answer:
// Disable #pcds
$('#pcds').attr('disabled', true);
// Enable #pcds
$('#pcds').attr('disabled', false);
4. Ques: What is the Document Ready Event syntax ?
Answer:
$(document).ready(function(){
});
5. Ques: Write a code for hide method of different selector ?
Answer:
<p id="myherder" class="myherderclass">This is a paragraph Element in html.</p>
$(this).hide() -its hides the current element.
$("p").hide() -its hides all <p> elements.
$(".myherderclass").hide() -its hides all elements with class="myherder".
$("#myherder").hide() - its hides the element with id="myherder".
6. Ques: Explain the code syntax and example of hide() and show() method in Jquery ?
Answer:
Syntax: $(selector).hide(speed,callback);
Ex:
<p id="ParaId">This is a paragraph Element in html.</p>
$("#ParaId").click(function(){
$("p").hide();
});
$("#ParaId").click(function(){
$("p").show();
});
7. Ques: What are the use of jQuery toggle() method ?
Answer:
toggle() method just toggle between the hide() and show() methods in jQuery ?
Ex:
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
No comments:
Post a Comment
Thank you for comment