0

I'm trying to resize a panel using JavaScript to fit a small image into a panel, and struggling badly.

It's within the bold:

<body id="visCinemaTransRefund"><br>
<div id="content"><br>
<ul class="PayPanel" id="paymentDetails"><br>

Here's the CSS that needs modifying:

visCinemaTransRefund .PayPanel { width: 435px; }

How would I be able to modify with width of this panel?

I've also got a form I'm trying to resize within CSS:

visCinemaTransRefund FORM (width: 1005px;)
Michael Morgan
  • 77
  • 1
  • 2
  • 6

5 Answers5

1

Have you tried using:

document.getElementById("paymentDetails").getElementsByClassName("PayPanel")[0].style.width="1000px"

Remember: getElementsByClassName return an array of elements, so using [0] you are indexing first element (and, of course, the only one).

Since getElementsById return a single elements, getElementsByClassName could be useless.

insilenzio
  • 918
  • 1
  • 9
  • 23
1
document.getElementById('paymentDetails').style.width = '1000px';
Alien
  • 3,658
  • 1
  • 16
  • 33
0

Use the following code to change the width of tags by accessing HTML element from the DOM using getElement functions and setting width to it using setAttribute javaScript function.

document.getElementById("paymentDetails").setAttribute("style","width:500px;");
document.getElementById("visCinemaTransRefund").getElementsByTagName("form")[0].setAttribute("style","width:1000px;");
Vinod Dalvi
  • 389
  • 1
  • 4
  • 33
0

If you want to do this using CSS class :

HTML:

<div id="myDiv" class="medium"></div>
<button id="btn">Click me</button>

CSS:

#myDiv {
    background-color: gray;
}

.medium {
       height: 50px;
       width: 50px;
}

.big {
       height: 100px;
       width: 100px;
}

JS:

document.getElementById("btn").onclick = function() {
    var element = document.getElementById("myDiv"); // or document.getElementsByClassName("className")

    if (element.className == "medium") {
        document.getElementById("myDiv").className = "big";
    } else {
        document.getElementById("myDiv").className = "medium";
    }
};

JSFIDDLE

Elfayer
  • 4,411
  • 9
  • 46
  • 76
0

Using JavaScript:

document.getElementById('paymentDetails').style.width = '1000px';

Using JQuery:

$("paymentDetails").width(1000);

$("paymentDetails").css("width","1000px");