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())});
精彩评论