Reputation: 906
I wanna change the width of a css when the value of a text to change on value.
Javascript:
<script>
$("inpu").change( function() {
$(#calidad).css({
width: function(index, value) {
return parseFloat(value) * 1.2;
},
});
});
</script>
CSS :
#calidad{ width: 20px; height: 15px; background-color: #f33; }
html:
<input type="text" id="inpu" name="inpu" value="2">
<div id="calidad"></div>
Upvotes: 0
Views: 482
Reputation: 19645
I may not understand the question, but do you want to change the width to the val of the input?
here is an example using px (you could use em, points, etc)
$(function() {
$("#inpu").change( function() {
$('#calidad').css({
width: getWidth});
});
});
function getWidth() {
return $('#inpu').val() + 'px'
}
here is a live example using a forked version of Steve's fiddle: http://jsfiddle.net/pK2qR/
Upvotes: 0
Reputation: 20620
I fixed your code and made a jsFiddle:
Both selectors were incorrect.
Upvotes: 2