gpt4 book ai didi

javascript - jquery 动态更新对象数据值?

转载 作者:行者123 更新时间:2023-11-30 13:07:15 24 4
gpt4 key购买 nike

网址

http://localhost/news-events/news.html?file=hosted_service.pdf

js代码

parseURL : function() {
var _path = window.location.pathname;
console.log(_path);
var _locationSearch = location.search;
var _locationParse = _locationSearch.replace('?file=','');
console.log(_locationParse);
var filePath = "/pdffiles/"+_locationParse ; // /pdffiles/hosted_service.pdf
$('.divEmbed object').data(filePath); **How to set the data of object? this is wrong**
console.log(filePath);
}

HTML

<div class="divEmbed">
<object data="" type="application/pdf">
alt : It appears you don't have a PDF plugin for this browser.
Click <a href="">here</a> to Download the file.
</object>
</div>

如果我想添加 object = filepath 的数据,语法是什么

最佳答案

您正在设置 jQuery 的数据对象,而实际上您想要的是更改普通属性。改用这个:

$('.divEmbed object').attr('data', filePath);

关于javascript - jquery 动态更新对象数据值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15237701/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com