开发者

apply methods of most objects jquery

开发者 https://www.devze.com 2023-03-16 11:58 出处:网络
e.g. var $magicLine = $(\"#magic-line\"); var $magicLine2 = $(\"#ma开发者_运维技巧gic-line2\"); how do I apply the methods to two objects?

e.g.

var $magicLine = $("#magic-line");
var $magicLine2 = $("#ma开发者_运维技巧gic-line2");

how do I apply the methods to two objects? I now use:

$magicLine.width($(".current_page_item").width()
$magicLine2.width($(".current_page_item").width()

if i use this method the programm not work:

$magicLine.width($(".current_page_item").width()


$("#magic-line, #magic-line2").width($(".current_page_item").width());

your question is a bit vague, i think you mean to use one call for both?


Do you mean to write?

var magicLine = $("#magic-line");
var magicLine2 = $("#magic-line2");

$magicLine.width($(magicLine).width());
$magicLine2.width($(magicLine2).width());


Try doing

var magicLine = $("#magic-line");

magicLine.width($(".current_page_item").width());


try

$magicLine.width($(".current_page_item").width());
$magicLine2.width($(".current_page_item").width());

you may choose this:

$.each([$magicLine, $magicLine2],function(i, value){value.width($(".current_page_item").width())});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号