user823415
user823415

Reputation: 57

apply methods of most objects jquery

e.g.

var $magicLine = $("#magic-line");
var $magicLine2 = $("#magic-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()

Upvotes: 0

Views: 86

Answers (4)

thecodeparadox
thecodeparadox

Reputation: 87073

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())});

Upvotes: 0

Sandeep Bhat
Sandeep Bhat

Reputation: 165

Try doing

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

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

Upvotes: 0

moe
moe

Reputation: 29704

$("#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?

Upvotes: 1

BonyT
BonyT

Reputation: 10940

Do you mean to write?

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

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

Upvotes: 0

Related Questions