Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.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/73.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更改HTML标记的属性_Javascript_Jquery - Fatal编程技术网

Javascript 使用jQuery更改HTML标记的属性

Javascript 使用jQuery更改HTML标记的属性,javascript,jquery,Javascript,Jquery,我试图使用jQuery更改标记的属性,但它不起作用。我正在尝试将标记的src属性从www.google.com更改为www.somewebsite.com。谁能告诉我哪里弄错了 <p class="form-row text-varient"> <label class="checkbox"> Some text here <a target="_blank" href="http://google.com">Link

我试图使用jQuery更改
标记的属性,但它不起作用。我正在尝试将
标记的
src
属性从
www.google.com
更改为
www.somewebsite.com
。谁能告诉我哪里弄错了

<p class="form-row text-varient">
    <label class="checkbox">
        Some text here
        <a target="_blank" href="http://google.com">Link Text</a>
    </label>
</p>
试试这个:

<p class="form-row text-varient">
<label class="checkbox">
    Some text here
    <a target="_blank" href="http://google.com">Link Text</a>
</label>
</p>

<script>

$(document).ready(function(){

    $(".checkbox a").attr("href", "http://www.somewebsite.com");

});



</script>

这里有一些文字

$(文档).ready(函数(){ $(“.checkbox a”).attr(“href”,”http://www.somewebsite.com"); });
试试这个:

<p class="form-row text-varient">
<label class="checkbox">
    Some text here
    <a target="_blank" href="http://google.com">Link Text</a>
</label>
</p>

<script>

$(document).ready(function(){

    $(".checkbox a").attr("href", "http://www.somewebsite.com");

});



</script>

这里有一些文字

$(文档).ready(函数(){ $(“.checkbox a”).attr(“href”,”http://www.somewebsite.com"); });


术语
来自哪里?它在您提供的HTML中不可见。
.terms
元素在哪里?此代码不起作用的唯一原因是该元素不在源代码中。是否有一个类为
terms
的元素?它不是它的terms。text varientWell,根据您的更新,代码可以正常工作:。如果仍然存在问题,请检查控制台是否有错误。
.terms
来自何处?它在您提供的HTML中不可见。
.terms
元素在哪里?此代码不起作用的唯一原因是该元素不在源代码中。是否有一个类为
terms
的元素?它不是它的terms。text varientWell,根据您的更新,代码可以正常工作:。如果您仍然存在问题,请检查控制台是否有错误。感谢您的回复,但这将更改网站中标记的所有属性我希望更改此特定属性感谢您的回复,但这将更改网站中标记的所有属性我希望更改此特定属性