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
54
votes
1 answer

jQuery data() returns undefined, attr() returns integer

I have the following code: alert($embellishment.data("embellishmentId")); alert($embellishment.attr("data-embellishmentId")); The first alert returns undefined, whereas the second alert returns an integer, 3. -- SEE DEMO -- I'm using jQuery version…
Curt
  • 94,964
  • 60
  • 257
  • 340
52
votes
9 answers

jQuery .attr("disabled", "disabled") not working in Chrome

Not sure why this isn't working. When people click the 'edit' button of my application, the disabled textfields become editable: $("#bewerken").click(function(e) { $("input[disabled='disabled']").removeAttr('disabled'); }); I then want to…
Joris Ooms
  • 10,952
  • 17
  • 63
  • 120
7
votes
2 answers

Jquery Disable option in dropdown

Guys i have used the following code to disable an option using jQuery (jquery-1.4.2.min).The disable happens in Firefox , but not in IE.
Dead Programmer
  • 11,879
  • 20
  • 75
  • 110
4
votes
2 answers

Why does jQuery always return 'open' for $.attr('open'), regardless of the actual value of the attribute?

In jQuery, why does this: $('
').attr('open') Always evaluate to 'open' instead of 'whatever'? In contrast, this: $('
').attr('asdf') Evaluates to 'whatever' as expected. Yes, I am aware that open and asdf…
Ben Lee
  • 50,019
  • 12
  • 118
  • 142
3
votes
3 answers

jquery choosing methods

I love using the hide() and show() methods, but I've come across someone's scripting where they never use it. Instead I see them using attr() for anything related to display. $("#element").attr("style",…
coffeemonitor
  • 11,838
  • 33
  • 93
  • 146
3
votes
4 answers

Whats a cleaner way to append something to a link URL?

I've got this code so far, which isn't working: $('.passName').click(function(){ var schoolName = "18734"; var link = $(this).attr('href'); var newLink = link + schoolName; $(this).attr('href') = newLink; });
dezman
  • 15,356
  • 8
  • 48
  • 82
3
votes
2 answers

Disabling submit button halts request in chrome/IE8

I have a simple form with three-four input fields and a submit button. Functionality to be implemented: On clicking submit button, submit button should get disabled so that no other click on button can be done. I can't hide the button. Now as I am…
Aakash Sahai
  • 3,705
  • 6
  • 24
  • 40
2
votes
1 answer

AngularJS ng-repeat: Change Array

I want to change categoryAlpha into a different value (say, into categoryBeta) in the following HTML + AngularJS:

Since ng-repeat isn't a normal…
chakeda
  • 1,252
  • 1
  • 18
  • 32
2
votes
1 answer

jQuery's attr(...) in function parameter is undefined

I'm using a jQuery plugin called webuiPopover. It adds a popover to links. When the user hovers a link, the content of the popover is fetched through AJAX. This requires a certain url with appropriate parameters. So this is the code…
2
votes
2 answers

jQuery progressbar on changing image .attr('src')

I have an image declared in HTML as: image_01 I'm changing the image through jQuery: $('#man_img_file').attr('src', "images/image_02.gif"); Now I want to display a…
storvas
  • 97
  • 1
  • 5
1
vote
3 answers

Do an jquery .attr("href", "new url") on sevral objects not just one

I have a site that uses for example html element id="some_id" several times and I want to change all those elements with jquery, but when I run the jquery code: $("#some_id").attr("href", "new url"); Or for example $("#some_id").text("new text") I…
ganjan
  • 6,443
  • 22
  • 74
  • 126
1
vote
0 answers

Is it possible to set title attribute and value to the HTML tag on the login page?

As of known Wordpress 5.2.0, login_headertitle has been deprecated and it is suggested to use login_headertext instead. However, I like to display a text when the login image is hovered on the login page. For this reason, I want to add the title…
Habip Oğuz
  • 659
  • 3
  • 14
1
vote
1 answer

Callback to confirm that "SRC" attribute is set in IFRame

Need to show the popup only when the data is loaded inside IFrame successfully. Currently popup gets visible even if the source of IFrame doesn't get loaded. Here is the code snippet: $('#myIframe').attr('src', 'Student.aspx?roll=' +…
Pranav Kumar
  • 199
  • 1
  • 3
  • 13
1
vote
2 answers

How to target the event that you click and use for offset

I have several div elements. On the mousedown event I am getting the elements attribute that I clicked on and then using Jquery offset method, I can't seem to trigger the $(elt) properly, so that it picks up as Jquery. I am trying to use as least as…
Chris Tarasovs
  • 661
  • 1
  • 17
  • 46
1
2 3