Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.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
Javascript 脚本标记不起作用的jquery find()和remove()_Javascript_Jquery - Fatal编程技术网

Javascript 脚本标记不起作用的jquery find()和remove()

Javascript 脚本标记不起作用的jquery find()和remove(),javascript,jquery,Javascript,Jquery,我有下面的脚本,它成功地从给定字符串中删除了一个标记。但是现在的问题是,如果我不尝试删除脚本标记,下面的fun()函数会自动删除脚本标记。有人能给我解释一下吗 <script src="jquery-1.8.3.js"></script> <script> function fun(x) { alert(x); var html = $(x.bold()); html.find('p').remove(); retu

我有下面的脚本,它成功地从给定字符串中删除了一个标记。但是现在的问题是,如果我不尝试删除脚本标记,下面的fun()函数会自动删除脚本标记。有人能给我解释一下吗

<script src="jquery-1.8.3.js"></script>
<script>
  function fun(x)
  {
    alert(x);

    var html = $(x.bold()); 
    html.find('p').remove();
    return html.html();

    //alert(html);

  } 
</script>
<input type="button" value="click" onclick="alert(fun('<script>hello script</script><p>hello p</p><div>hello div</div>'))">

功能乐趣(x)
{
警报(x);
var html=$(x.bold());
html.find('p').remove();
返回html.html();
//警报(html);
} 

事实上,你会工作的,我想问题是你的jQuery没有正确添加

<script src="jquery-1.8.3.js"></script>  <!-- jQuery Lib is not added properly-->


这是一个相应的工作模式。

实际上您将工作,我想问题是您的
jQuery
没有正确添加

<script src="jquery-1.8.3.js"></script>  <!-- jQuery Lib is not added properly-->

这是一个相应的工作模式。

试试这个:

function fun(x)
{
  alert(x);

  var html = x.bold();       
  html=$(html);
  html.find('p').remove();
  return($(html).html());
} 
试试这个:

function fun(x)
{
  alert(x);

  var html = x.bold();       
  html=$(html);
  html.find('p').remove();
  return($(html).html());
} 

什么是
$(x.bold())
?它只是用我在网上找到的标签来包装字符串@user1671639看起来很好浏览器consolethanks@ArunPJohny中出现任何错误,但我复制粘贴了该函数并在我的pc中尝试,但失败了:(.var html=$('',{html:x})意味着什么?什么是
$(x.bold())
?它只是用我在网上找到的标记来包装字符串…@user1671639在浏览器consolethanks@ArunPJohny中看起来很好任何错误,但我复制粘贴了该函数并在我的电脑中尝试,失败了:(.var html=$('',{html:x})是什么意思;意思是?我甚至尝试过谷歌API的外部源,都是徒劳的。请给我任何建议!我甚至尝试过谷歌API的外部源,都是徒劳的。请给我任何建议!