Replace CSS attribute using Jquery/Javascript

I have following code which have a css class called "formErrorContent"

var promptContent = $('<div>').addClass("formErrorContent").

Before addiing the class as per the above code. I need to replace the width attribute with some other values like this


But the above line is not working and not setting the width attibute to 13 in the css class "formErrorContent"

Please help me on this ... Thanks


Try this:

$('<div/>', {
  'class': "formErrorContent",
   width: '13px',
   text: promptText

Use .css() and change the selector to class, because you set it as class:

var promptContent = $('<div>').addClass("formErrorContent").html(promptText).appendTo(prompt);

you are adding a class but are referring to an id. try


Need Your Help

1: command not found

bash variables numbers set sh

I'm writing a divides-by-three function in Bash, and it won't let me set a variable to a number.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.