- Script JQuery Selector Umum Digunakan
- Script JQuery Tambah dan Hapus Class CSS
- Script JQUERY Merubah dan Mendapatkan Nilai HTML Textbox
- Script JQuery Mendapatkan dan Merubah Elemen HTML
- Script JQuery Mendapatkan dan Merubah Elemen Input Textarea
- Script JQUERY Merubah Lebar dan Tinggi Elemen HTML
1. Script JQuery Merubah Properti CSS Script jquery berikut ini berfungsi merubah properti css ke dalam nilai yang anda tentukan.
//--- CHANGE AN ELEMENT'S CSS PROPERTY ---//
$("#DivID").css("background-color", "#000");
$("#DivID").css("border", "solid 2px #ff0000");
//--- JQUERY TOGGLE/SHOW/HIDE ---//
// toggle hide/show of an element
$("#DivID").toggle(1000);
// do something when animation is complete
$("#DivID").toggle(1000, function () {
alert("Toggle Complete");
});
// hide an element
$("#DivID").hide(1000);
// do something when animation is complete
$("#DivID").hide(1000, function () {
alert("Hide Complete");
});
// show an element
$("#DivID").show(1000);
// do something when animation is complete
$("#DivID").show(1000, function () {
alert("Show Complete");
});
//--- JQUERY SLIDE - SLIDE AN ELEMENT IN AND OUT ---//
// toggle slide up and down
$("#DivID").slideToggle(1000);
// do something when animation complete
$("#DivID").slideToggle(1000, function () {
alert("Slide Toggle Complete");
});
// slide up
$("#DivID").slideUp(1000);
// do something when animation is complete
$("#DivID").slideUp(1000, function () {
alert("Slide Up Complete");
});
// slide down
$("#DivID").slideDown(1000);
// do something when animation is complete
$("#DivID").slideDown(1000, function () {
alert("Slide Down Complete");
});
//--- JQUERY FADE - FADE AN ELEMENT IN, OUT & TO ---//
// fade in
$("#DivID").fadeIn(1000);
// do something when animation complete
$("#DivID").fadeIn(1000, function () {
alert("Fade In Complete");
});
// fade out
$("#DivID").fadeOut(1000);
// do something when animation is complete
$("#DivID").fadeOut(1000, function () {
alert("Fade Out Complete");
});
// fade to (fades to specified opacity)
$("#DivID").fadeTo(1000, 0.25);
// do something when animation is complete
$("#DivID").fadeTo(1000, 0.25, function () {
alert("Fade To Complete");
});
//--- ANIMATE (EXAMPLE USES OPACITY,
BUT CAN USE ANY CSS PROPERTY. ---//
//--- NOTE SOME MY REQUIRE THE USE OF
A PLUGIN SUCH AS JQUERY COLOR
ANIMATION PLUGIN. ---//
$("#DivID").animate({ opacity: 0.25 }, 1000);
// do something when animation complete
$("#DivID").animate({ opacity: 0.25 }, 1000, function
() {alert("Opacity Animation Complete");
});
<script type="text/javascript" language="javascript">
$(document).ready(function() {
// focus on the first text input field in
the first field on the page
$("input:text:visible:first").focus();
});
</script>
0 komentar:
Posting Komentar