【发布时间】:2018-03-30 20:07:00
【问题描述】:
这个post 和我有类似的问题。但是,它对我的情况没有帮助。
我有一个文本框,允许用户粘贴或输入网址。当点击分享按钮时,它将在文本框中分享该网址。
<div class="sharewrapurl">
<div id="shareurl_validation" style="display: none"> </div>
<input type="text" id="shareviaurl_url" class="textbox_with_url" name="shareviaurl_url" placeholder="Paste URL here.">
<div class="shareurlbutton">
<span id="fb_ut_urlshare" style="width:100px;"><span class="st_facebook_large" st_url="http://santosh-shah.com" st_title="#DVDNation #ad #DVD20" onclick="social_share_url(appConfig.FacebookPostWidgetConfigId)"></span></span>
<span id="tw_ut_urlshare" style="width:100px;"><span class="st_twitter_large" st_url="s" st_title="#DVDNation #ad #DVD20" onclick="social_share_url(appConfig.TwitterPostWidgetConfigId)"></span></span>
</div>
<!-- /.shareurlbutton -->
</div>
如果我直接点击 facebook 分享,那么它将分享我在 st_url 中的域名,但我想用输入框值更新该属性。
$('#shareviaurl_url').on('input propertychange paste', function() {
var url = $("#shareviaurl_url").val();
$("#shareurlbutton").find("#st_facebook_large").attr("st_url",url);
console.log($("#shareurlbutton").find("#st_facebook_large").attr("st_url"));//returns undefined.
});
【问题讨论】:
-
st_facebook_large 是一个类,但您正在查找函数中寻找一个 id
标签: javascript jquery facebook-sharer