Skip to content

Tag: attributes

html set title attribute to display line break

How can I display line-breaks for a hover event using title on a simple html-element? / What is the proper code to be used? I am trying to set the title attribute like so: ..That does not work. Is does not break anywhere. ……………….. — Code sample — Answer You were close, but used a slash instead of a backslash

Set attribute without value

How do I set a data attribute without adding a value in jQuery? I want this: I tried: Everything else seems to add the second arguments as a string. Is it possible to just set an attribute without value? Answer The attr() function is also a setter function. You can just pass it an empty string. An empty string will

set option “selected” attribute from dynamic created option

I have a dynamically created select option using a javascript function. the select object is when the js function is executed, the “country” object is and displaying “Indonesia” as default selected option. note : there is no selected=”selected” attribute in that option. then I need to set selected=”selected” attribute to “Indonesia”, and I use this using firebug, I can see

How can I remove an attribute with jQuery?

I can’t seem to get removeAttr to work, I’m using the example I saw on the jQuery site. Basically onclick I add the attribute to disable a field (which works just fine) but when the user clicks again it should enable the field in question. I used alerts to make sure the else block is being fired, so I know