1

I am using CSS3 resizable property to resize an HTML Div element.

Here is sample code : http://jsfiddle.net/blunderboy/nMTm9/1/

But, I want to update the value inside input element as soon as width of div changes. How can we achieve this ?

4
  • Have you looked at the jQueryUI resizeable implementation? It works across all browsers and fires a resize event when the element size is changed. Commented Oct 3, 2012 at 12:40
  • you want that to resize first the div and after that the value on the input fieald wil update ? Commented Oct 3, 2012 at 12:42
  • Yes I looked at jQueryUI but it will make site heavy. I was thinking if it is possible to do the same without using jquery because I dont want to download UI js file just for small purpose. @yossi: I want to update the input value as soon as div is resized. Commented Oct 3, 2012 at 12:47
  • I found this link davidwalsh.name/html5-placeholder-css it maybe it will help Commented Oct 3, 2012 at 13:08

2 Answers 2

3

With setInterval, you can do this:

http://jsfiddle.net/nMTm9/3/

It's not perfect but works great.

var input = $('input'), div = $('#resizable');
function calculate(){
    input.val(div.width()+"px");
}
setInterval(calculate,500);​
Sign up to request clarification or add additional context in comments.

1 Comment

This is just brilliant stuff. Although not ideal but really really appreciable. Thanks a lot :) :)..Works for me..
1

No, CSS cannot change the value attribute of an input, or indeed any attribute of any element.

The close change content by style is if you put content in the input field or erased the content input field the label change by css.

enter link description here

1 Comment

Can't we add some listener to height and width of div. That is whenever they are changed, the handler is invoked and that will update the value in input. THANKS BTW

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.