Style: $ (function (){
$ ("Tag to be selected"). click (function () {alert ("pop-up dialog box content ");})
});
First: Id Selector
Usage:
Copy codeThe Code is as follows:
<Head>
<Title> </title>
<Script src = "Jq/jquery-1.4.2.js" type = "text/javascript"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ("P"). click (function () {alert ("Small P ");})
});
</Script>
</Head>
<Body>
<Input type = "button" value = "PlayGame" id = "btnClick"/>
<P> first </p>
<P> second </p>
</Body>
Note: A dialog box is displayed for all <P> tag clicks.
Type 2: CSS Selector
Copy codeThe Code is as follows:
<Head>
<Title> </title>
<Script src = "Jq/jquery-1.4.2.js" type = "text/javascript"> </script>
<Script type = "text/javascript">
$ (Function (){
$ (". Warning"). click (function () {alert ("this is a warning message ");});
});
</Script>
<Style type = "text/css">
. Warning {background-color: Yellow; color: Red ;}
</Style>
</Head>
<Body>
<P> no warning </p>
<Div class = "warning"> Please bring your child </div>
<P class = "warning"> warn you again </p>
<Input class = "warning" type = "button" value = "don't click"/>
</Body>
Note: A dialog box is displayed when you click. warning for all CSS styles.
Third: Multi-condition Selector
Copy codeThe Code is as follows:
<Head>
<Title> </title>
<Script src = "Jq/jquery-1.4.2.js"> </script>
<Script type = "text/javascript">
$ (Function (){
$ (". Docc, p, # txt1"). click (function () {alert ("don't be fooled ");})
})
</Script>
<Style type = "text/css">
. Docc {background-color: Fuchsia; color: Olive ;}
</Style>
</Head>
<Body>
<P> selling computers </p>
<Input type = "text" id = "txt1"/>
<Input class = "docc" type = "button" value = ""/>
<Input type = "checkbox"/>
</Body>
Note: You can process multiple selected items at the same time.