Jquery 为什么此代码不动态设置文档标题?
我试图定期从php脚本中动态更新文档标题,但似乎不起作用。我是jquery的初学者,请帮助Jquery 为什么此代码不动态设置文档标题?,jquery,Jquery,我试图定期从php脚本中动态更新文档标题,但似乎不起作用。我是jquery的初学者,请帮助 <div id="code" style="border: 1px solid; "></div> <script> var blink = true; setInterval(function(){ if(blink){ jQuery('#code').load('test.php', function(result)
<div id="code" style="border: 1px solid; "></div>
<script>
var blink = true;
setInterval(function(){
if(blink){
jQuery('#code').load('test.php', function(result) {
var theTitle = document.getElementsByTagName("title")[0];
theTitle= 'google'+jQuery('#code').html();
});
//theTitle.text =document.getElementById('code').value;
blink = false;
}else{
jQuery('#code').load('test.php', function(result) {
var theTitle = document.getElementsByTagName("title")[0];
theTitle= 'yahoo'+jQuery('#code').html();
});
blink = true;
}
}, 2000);
var闪烁=真;
setInterval(函数(){
如果(闪烁){
jQuery('#code').load('test.php',函数(结果){
var theTitle=document.getElementsByTagName(“标题”)[0];
标题='google'+jQuery('#code').html();
});
//title.text=document.getElementById('code').value;
闪烁=假;
}否则{
jQuery('#code').load('test.php',函数(结果){
var theTitle=document.getElementsByTagName(“标题”)[0];
标题='yahoo'+jQuery('#code').html();
});
闪烁=真;
}
}, 2000);
试试看-
document.title = "new page title."
试一试-
如果使用jquery,请尝试以下操作:
var blink = true;
setInterval(function(){
$('#code').load('test.php', function(result) {
$('title').text(blink ? 'google'+$('#code').html() : 'yahoo'+$('#code').html());
blink = !blink;
});
}, 2000);
如果使用jquery,请尝试以下操作:
var blink = true;
setInterval(function(){
$('#code').load('test.php', function(result) {
$('title').text(blink ? 'google'+$('#code').html() : 'yahoo'+$('#code').html());
blink = !blink;
});
}, 2000);