如何使用jQuery使用css选择器?

如何使用jQuery使用css选择器?,jquery,html,css,Jquery,Html,Css,jQuery在HTML页面加载时调用一个函数,该函数将在所有具有css“Hello”的标签上设置文本“Hello world!” 有人能告诉我一点这方面的情况吗?用类hello选择所有元素。在HTML页面准备就绪时: $(document).ready(function(){ $(".hello").each(function(index){ /* do stuff */ }); }); 试试这个: $(document).ready(function(){ $

jQuery在HTML页面加载时调用一个函数,该函数将在所有具有css“Hello”的标签上设置文本“Hello world!”


有人能告诉我一点这方面的情况吗?

用类hello选择所有元素。在HTML页面准备就绪时:

$(document).ready(function(){
    $(".hello").each(function(index){
        /* do stuff */
    });
});
试试这个:

$(document).ready(function(){ $(".hello").Text("hello world"); });

如果仍然不起作用,请检查jQuery是否已加载

谷歌快速搜索可能会对您有所帮助。什么是“css hello”?在提问之前,花些时间阅读并做一些基础研究。这对你在进行j query之前对html进行修改很有好处!我没有得到兄弟。。。我知道html,但是jquerywe的初学者如果你没有写一个可以理解的目标和问题,并且没有提供相关的html结构$(document).ready(function(){$(“.hello”).each(function(index){$(“:label”).css(“background color”,“yellow”);});文本必须是小写的,他希望为每个文本运行代码,而不是更改文本。