Jquery and Ajax Documentation: Script Link
Jquery and Ajax Documentation: Script Link
pg. 1 Saikumar
JQUERY AND AJAX DOCUMENTATION
</body>
</html>
});
jQuery Selector:
jQuery selectors allow you to select and manipulate HTML element(s).
jQuery selectors are used to "find" (or select) HTML elements based on their
name, id, classes, types, attributes, values of attributes and much more. It's
based on the existing css selectors, and in addition, it has some own custom
selectors.
All selectors in jQuery start with the dollar sign and parentheses: $().
pg. 2 Saikumar
JQUERY AND AJAX DOCUMENTATION
An id should be unique within a page, so you should use the #id selector when
you want to find a single, unique element.
To find an element with a specific id, write a hash character, followed by the id
of the HTML element:
Ex:
$(‘#Id’)—here id may be input filed id ,paragraph id, div id
If you want get that value in JavaScript u need to use below syntax.
Var fname=document.getElementById(“fn”).value;
When ever my page loads I need to make cursor on email first.so if you use
onfocus directly it will go to specific input field.
pg. 3 Saikumar
JQUERY AND AJAX DOCUMENTATION
pg. 4 Saikumar
JQUERY AND AJAX DOCUMENTATION
<p style="color:red"></p>
</body>
</html>
Hide the div or paragraph or input filed then use hide():
$("#id").hide();
$("#id").hide(2000);-we can pass time also in milli seconds
$("#id").hide(“show”,function()
{
Alert(“inside hide”);
}
);-----we can have another function also
Method Chaining:
<script>
$(document).ready(function(){
$("button").click(function(){
$("#p1").css("color", "red").slideUp(2000).slideDown(2000);
});
});
</script>
pg. 5 Saikumar
JQUERY AND AJAX DOCUMENTATION
JQuery Get:
Example for get a text from paragraph
<script>
$(document).ready(function(){
$("#btn1").click(function(){
alert("Text: " + $("#test").text());
});
$("#btn2").click(function(){
alert("HTML: " + $("#test").html());
});
});
</script>
Example for get a value from input fields:
<script>
$(document).ready(function(){
$("button").click(function(){
//use
Var data=$(“#test”).val();
(Or)
alert("Value: " + $("#test").val());
});
});
</script>
Similarly u can set value also like:
$(“#test”).val(“new test value”);
pg. 6 Saikumar
JQUERY AND AJAX DOCUMENTATION
pg. 7 Saikumar
JQUERY AND AJAX DOCUMENTATION
pg. 8 Saikumar