Questions tagged [jquery-attributes]

Attributes provide additional information about HTML elements. jQuery have built-in methods that allow you to get and set DOM attributes of elements.

Attributes provide additional information about HTML elements.

  • HTML elements can have attributes
  • Attributes provide additional information about an element
  • Attributes are always specified in the start tag
  • Attributes come in name/value pairs like: name="value"

jQuery have built-in methods that allow you to get and set DOM attributes of elements. Some of the useful jQuery attributes manipulation methods are:

  • .attr() - Get the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element.
  • .removeAttr() - Remove an attribute from each element in the set of matched elements.

Resource

45 questions
0
votes
2 answers

Picking and calling original css with data() and attr() works in Firefox, but not in Opera and Chrome?

I want to be able to reset draggable div to it's original position after dragging (jquery ui draggable()) on some event in jquery. I did this: $('#nav').draggable(); $('#nav').data({'x': $("#nav").css('left'), 'y':…
0
votes
0 answers

jQueryMobile Change listview's item attributes dynamically

I want to change dynamically (click event) a data-theme of a list item in a jQueryMobile listview. Firebug shows me that the change is performed but the list is not refreshed. (If I add elements it works, but with attribute changes the list won't be…
0
votes
5 answers

JQuery Toggle Image not working

I am simply trying to toggle the image source with a click using JQuery. My script is below, I am not sure why it's not toggling. When the page first loads, if you click the gray image, it toggles to the color image. But if you click the gray…
thenextmogul
  • 1,143
  • 2
  • 10
  • 20
0
votes
3 answers

Jquery : Attribute Start With for current element

Attribute "Start With" in jquery is very simple, but i have a problem How use this attribute for current element? As example i tried: $('this[id^= "PostTypes"]') AND $(this[id^= "PostTypes"]) But nothing want works.
user2167382
  • 346
  • 1
  • 3
  • 14
0
votes
2 answers

Use find data attribute to add class

I am attempting to create a menu with unique data attributes attached to each navigation item. On click I want that navigation item to find the section with the same attribute and add a class to it. This is the code I am using thus-far (it is part…
bmlbml
  • 23
  • 4
0
votes
2 answers

jQuery checking and unchecking checkboxes

I have to check and uncheck the checkboxes. But it is not working well. Example: When the status is active on the 1st load: Unchecking the checkboxes into inactive (Works fine) Checking it back again to make it active (Not working, stays…
justin
  • 1,659
  • 5
  • 21
  • 25
0
votes
1 answer

Code is selecting wrong element to animate

I'm trying to get my jquery to select a different element based on a value stored in the clicked elements attribues. But it keeps animating the clicked element. Because there are multiple classes named element1 I figured this would be the easiest…
AtlasOnEarth
  • 83
  • 1
  • 2
  • 7
0
votes
4 answers

JQuery Wildcard for using atttributes in selectors

I've research this topic extensibly and I'm asking as a last resort before assuming that there is no wildcard for what I want to do. I need to pull up all the text input elements from the document and add it to an array. However, I only want to add…
rocklandcitizen
  • 979
  • 4
  • 17
  • 27
0
votes
1 answer

Why isn't IE8 finding these attributes?

I get the alerts and expected behavior in IE 9 and everything else, but no such luck in IE 8. What could be the cause of this? container.find('[style*="left:"],[data-item-left],[style*="top:"],[data-item-top]').each(function(index){ //…
user396070
0
votes
3 answers

jquery: .attr() fails for child element

I'm going crazy staring at this. I need to change the attribute of an element, something which I have done many times before. But it fails. Now I can't even get jquery to show me the attribute that it has. Does it have to do with what is returned by…
user984003
  • 28,050
  • 64
  • 189
  • 285
-1
votes
3 answers

jQuery Inverse of Selection

Give the code below, I want to select only those divs that have a data-PType attribute containing ABC or DEF or GHI. In the listing below then, I want to select divs with ids 1, 3 and 5. I also need a second selection of all divs where the…
Tom Baxter
  • 2,110
  • 2
  • 19
  • 38
-1
votes
3 answers

jQuery change all attributes within a form to something else

I have a form with form elements such as follows: @using (Html.BeginForm("Edit", "UserProfile", FormMethod.Post, new { id = "EditUserForm", @class = "form-horizontal form-bordered" })) {
@Html.LabelFor(m =>…
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
-2
votes
1 answer

How to create elements of form using jquery

My code is