TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Hazel Mahmud
1.4k
315
70k
textbox length according to text
May 27 2015 3:23 AM
i have code that dynamically addtextbox but when i add onkeyup function, it work in Chrome and Firefox but it doesn't work in IE.. code that does not work is after the text with red colour. TQ so much.
$(document).ready(function () {
var counter = 2;
$("#btnAdd").click(function () {
if (counter > 4) {
return false;
}
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.after().html('<input type="text" name="textbox' + counter + '" size="1' +
'" onkeyup="Expand(this);"'
+ '" id="textbox' + counter + '" value="">');
newTextBoxDiv.appendTo("#LinkTab");
$('#textbox' + counter).focus();
counter++;
});
code below does not work in IE.. help me how to fix it anyone.
function Expand(obj) {
if (!obj.startW) { obj.startW = obj.offsetWidth; }
var style = obj.style;
//Force complete recalculation of width
//in case characters are deleted and not added:
style.width = 0;
var desiredW = obj.scrollWidth;
desiredW += obj.offsetHeight;
style.width = Math.max(desiredW, obj.startW) + 'px';
}
Reply
Answers (
5
)
Disable all textbox based on value in jqquery
sort row data