【发布时间】:2014-03-21 04:05:43
【问题描述】:
选择,我的意思是select()
我的代码是这样的:
$('.show-embed-link').unbind('click');
$(".show-embed-link").click(function(e){
var id = $(this).attr("rel");
e.preventDefault();
showEmbed(id);
setTimeout(function() {
$("#general_message").focus();
}, 100);
});
.show-embed-link 不是动态元素。它是一个<a> 元素。
showEmbed 将生成一个动态元素。
function showEmbed(id) {
var message = '<iframe width="1000" height="800" src="//storyzer.com/stories/'+id+'" frameborder="0" allowfullscreen></iframe>';
message = HtmlEncode(message);
showOverlayForGeneral(message, "Embed work", {'spinner': false, 'extraheight': 90, 'showclose': true});
}
showOverlayForGeneral负责生成带有消息的动态元素。
function showOverlayForGeneral(message, title, options) {
options = (typeof options === "undefined") ? {} : options;
var defaultOptions = {
"message": "",
"extraheight": 150,
"spinner": true,
"showclose": false
};
// code removed because not relevant to this situation...
$('#general_message').unbind('focus');
$('#general_message').focus(function () {
$('#general_message').select().mouseup(function (e) {
e.preventDefault();
$(this).unbind("mouseup");
});
});
}
focus 代码取自 https://stackoverflow.com/a/3380493
目前,我的 div html 未被选中。如何判断 select 事件是否正在发生?
【问题讨论】:
-
看看
.on()api.jquery.com/on -
我应该如何使用它?
-
你已经提供了你尝试过的东西。
标签: javascript jquery html select