Teacher, why can't I run the code you taught me?
iUnicorn
iUnicorn 2019-03-19 15:14:55
0
5
1653

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
< ;title>Traverse jquery objects</title>
<script src="../jquery-3.3.1.js"></script>
<script>
$( "button").click(function () {
                                                                                                                                                                 .                More functions can be completed.
$("li").each(function (i) {
                    $(this).css("color","red").html(i "---" "www.php.cn");
});
})
     
                                                                                   ;button type="button" name="button">Please click to change color</button>
<ul>
;PHP Chinese website 02</li>
;/li>
</ul>
</body>
</html>

iUnicorn
iUnicorn

知识,成就梦想!

reply all(2)
Alone88

If your js code is written on <body>, you need to add the entry function

  • reply It should be unnecessary, just put the script code at the back. thanks for the reply
    iUnicorn author 2019-03-20 17:00:15
小灰

<!DOCTYPE html>

<html lang="zh-CN">

<head>

<meta charset="UTF -8">

<title>Traverse jquery object</title>

</head>

<body>

<button type="button" name="button">Please click to change color</button>

<ul>

<li>PHP Chinese website 01</li&gt ;

<li>PHP Chinese website 02</li>

<li>PHP Chinese website 03</li>

<li>PHP Chinese website 04</li>

<li>PHP Chinese website 05</li>

</ul>

</body>

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

<script>

$("button").click(function () {

//The above line of commented code can use this function to complete more functions.

$("li") .each(function (i) {

$(this).css("color","red").html(i+"---"+"www.php.cn");

});

})

</script>

</html>


  • reply Thanks for the reply, I changed the location and solved it. Thanks again! ! Haha~~
    iUnicorn author 2019-03-20 16:59:33
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template