1

I have a problem, I want to set the width for an object using jquery, My object

<object id="game" width="960" height="560" style="visibility: visible; width: 0px;">

So I want to set width : 960 --> 0 I tried like this but not work :

document.getElementById("game").width = "0px";

Can you help me please? Thx in advance

3 Answers 3

1

Using javascript you can use:

document.getElementById("game").style.width = "0px";

You need to use the style property and then you can set the width and not directly.

Using jquery you can use the following code:

$("#game").width(0);
Sign up to request clarification or add additional context in comments.

Comments

1

Does this work for you?

$('#game').width(0);

It sets width to number of pixels specified by parameter. You can also use strings like '0px' or other units like '%'. jQuery documentation

Comments

1

Or you can try this jQuery:

$("#game").attr("width", "0px");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.