![](/img/trans.png)
[英]Is there a way to trigger an event when mapping out a Component so that it only applies a style to that specific component?
[英]Is there a way to edit this script so that it only applies to a specific select class?
有没有办法编辑这个脚本,以便它只适用于特定的选择类而不适用于页面中的所有标签?
(此脚本用于扩展下拉列表选项,以便它们不会在IE中被截断。)我们想要发生的是仅将此应用于选择具有很长选项名称的标记。
<script>// Safely use $
(function($) {
$.fn._ie_select=function() {
return $(this).each(function() {
var a = $(this),
p = a.parent();
p.css('position','relative');
var o = a.position(),
h = a.outerHeight(),
l = o.left,
t = o.top;
var c = a.clone(true);
$.data(c,'element',a);
c.css({
zIndex : 100,
height : h,
top : t,
left : l,
position : 'absolute',
width : 'auto',
opacity : 0
}).attr({
id : this.id + '-clone',
name : this.name + '-clone'
}).change(function() {
$.data(c,'element')
.val($(this).val())
.trigger('change')
});
a.before(c).click(function() {
c.trigger('click');
});
}); // END RETURN
}; // END PLUGIN
if ($.browser.msie) {
$('select')._ie_select();
}
})(jQuery); // END SAFETY</script>
底部的代码似乎是选择器的一部分,所以改变
if ($.browser.msie) {
$('select')._ie_select();
}
至
if ($.browser.msie) {
$('select.classNameHere')._ie_select();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.