lundi 2 février 2015

Link the width of a div to a var

I was trying to use this code:



$("#a").click(function(event) {

var n = $("#uno").innerWidth();
var a = $("#due").innerWidth();

if (n = a) {
$("#uno").css('width', '1000px');
} else {
$("#uno").css('width', '400px')
}
event.preventDefault();
});


So that when i click on that link, if the width of the div #uno matches the width of the other div, I get it to a width of 1000px, and if not, it returns to a width of 400px. This is the idea, but I can't get it to work.


Aucun commentaire:

Enregistrer un commentaire