Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从<;p>;使用javascript标记?_Javascript_Html_Javascript Events - Fatal编程技术网

如何从<;p>;使用javascript标记?

如何从<;p>;使用javascript标记?,javascript,html,javascript-events,Javascript,Html,Javascript Events,我想在三秒钟后使用setInterval()方法更改p标记的内容。然后在3秒钟后,我想更改p标记内部的内容,新的间隔为5秒钟。这是我的代码片段 background.js var通知; var word=function(){ $.get(”http://localhost/chrome-notification/dosya.php,函数(数据){ $('#container').html(数据); }); }; 设置间隔(字,3000); setInterval(函数(){ $.get(”h

我想在三秒钟后使用
setInterval()
方法更改p标记的内容。然后在3秒钟后,我想更改p标记内部的内容,新的间隔为5秒钟。这是我的代码片段

background.js

var通知;
var word=function(){
$.get(”http://localhost/chrome-notification/dosya.php,函数(数据){
$('#container').html(数据);
});
};
设置间隔(字,3000);
setInterval(函数(){
$.get(”http://localhost/chrome-notification/“,功能(响应){
notify=$(response).getElementsByTagName('p')[0].innerHTML;
});

},5000);如果我理解得好,我建议添加CSS并将其链接到html。 (如果这就是你需要它的原因)


在css中创建标记并自定义它

因为您使用的是jQuery,所以只需执行
$(response).find('p:eq(0)').html()


我在这里写了更多的例子,这可以在纯js中完成

var text = document.getElementById('container').innerHTML;

这就是您需要的吗?

可能与不起作用的内容重复?@RayonDabre notify variable没有获取p tag的值。当我发出警报(notify)时,获取未定义的消息。请尝试调试您的应用程序,
警报($(response)。find('p').size())
是否会因此为您提供多个警报?如果是这样,则在响应中找到
p
标记。p标记未获取值。因为alert($(response).find('p').size())返回0,这意味着您的
response
不包含任何
p
标记。响应返回html页面内容