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
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
  • 703
  • 2
  • 21
  • 54
1
vote
2 answers

jQuery change images on links hover

I have a problem with a code below. Somehow I'm not able to change image background using jQuery script. HTML code looks like: part to display an image:
part to generate related links…
user961694
1
vote
1 answer

jQuery .on() click runs correctly only once

I have created following small code to replicate the problem I am actually facing. When I click on "Select All" button for the first time it works fine. Similarly when i click on "Select None" button it works fine. But when I click "Select All"…
Saad Bashir
  • 4,341
  • 8
  • 30
  • 60
1
vote
3 answers

Replace img attribute only works first time

So I have this jQuery function: $('ul li').click(function () { var title = $('img', this).attr("title"); $("a.songtitle span").text(title); var artist = $('img', this).attr("artist"); $("a.songartist span").text(artist); var…
jick
  • 168
  • 2
  • 14
1
vote
3 answers

jQuery .attr doesn't attribute width or height

The following code attributes the src to .ajax-loader which is an img but not the height or width. Am I doing something wrong? $(".ajax-loader").attr({ src: "http://test.com/loading.gif", height: 16, width: 16 }); Edit: This is…
J82
  • 8,267
  • 23
  • 58
  • 87
1
vote
3 answers

jQuery . what does $('') mean?

Possible Duplicate: What does the selector syntax mean in $( “
” ).text( message ) I've searched but couldn't find any info on this... including the jQuery reference... What does $('') mean in jQuery? I am familiar with $('img')…
nunomira
  • 390
  • 4
  • 14
0
votes
2 answers

Check if value is in dropdown list and disable it in Jquery

How can i check if an item is in a select drop down list and disable it if it fulfills some condition? Thanks in advance! BTW i tried the following and nothing is happening $('#select-box option').each(function() {if (this.val() == item) …
Stanwin Siow
  • 437
  • 1
  • 8
  • 21
0
votes
3 answers

How do I perform an OR search on jQuery attributes?

I have a bunch of li items that have some custom attributes:
  • foo
  • foo1
  • foo2
  • foobar
  • bar2
  • bar3
I'd like to select those li…
David Hoerster
  • 28,421
  • 8
  • 67
  • 102
0
votes
3 answers

jQuery select elements when attribute is contained in attribute list?

Better explain with an example (i'm very new to jQuery, sorry in advance): // Selector for checkboxes not checked var checkboxes = "input:checkbox:not(:checked)"; // Selector for labels relative to checkboxes not checked var labels = "label[for=" +…
gremo
  • 47,186
  • 75
  • 257
  • 421
0
votes
1 answer

jQuery Dialog Squeeze Height

I am trying to squeeze the entire height of a dialog box I created with jQuery UI down to a height of 0px once the dialog is created. I cannot use the dialog's "height" property, and set that to 0, as I need everything to be squished down. Here is a…
Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
0
votes
1 answer

jquery - get id attr of (this)

An anchor tag similar to this is clicked. Click Me $(this)[0] contains a string similar to http://localhost/www/go.php?3aaa I wish to strip the "3" and "aaa" (values change according to what is clicked) into their own…
user674073
  • 159
  • 1
  • 4
  • 14
0
votes
1 answer

Reading src attribute to generate href

I am using a lightbox called nyromodal and I am calling it manually on some thumbnail images to open a larger image. Code: onclickActiveItem: function (item) { $('img.active').click(function(e) { e.preventDefault(); …
Macsupport
  • 5,406
  • 4
  • 29
  • 45
0
votes
1 answer

Loading meta data from another page using jQuery

I'm trying to use the jQuery load method to grab some meta data from another page and insert it in a
, but I'm a little stuck. I'm using something similar on the other page in which I grab the location meta data and put it in a

. To do this…

0
votes
2 answers

Add specific attribute Jquery

I want to add an attr data-columns into
Like this :
I try it but it does not work : $('#portfolio').attr("data-columns"); Thanks for your help !
Corentin Branquet
  • 1,556
  • 3
  • 17
  • 29
0
votes
3 answers

jQuery - update image url only folder

How can I update, Image URL only some part of it... For Eg: I have 2 folders, if images coming from lenovo folder, I want change that folder to samsung to
Reddy
  • 1,477
  • 29
  • 79