Questions tagged [attr]

This tag should be used for attribute related issues.

An attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such.

1197 questions
20
votes
6 answers

Get href attribute on jQuery

I have some table rows
BILL
  • 4,303
  • 10
  • 51
  • 91
19
votes
2 answers

Css Content, Attr and Url in the same sentence

I have used the content attribute for a long time, and today I wanted to try something new. Instead of using JS to display a image tooltip I wanted to know if it was possible to do it dynamically with CSS. So I tried: .TableLine:hover:after{ …
h1fra
  • 305
  • 1
  • 2
  • 9
15
votes
2 answers

JQuery $(this).attr("name") vs this.name

What is the main different between $(this).attr("name") and this.name and What is the technical explanation?
Sameera Thilakasiri
  • 8,933
  • 8
  • 49
  • 80
14
votes
4 answers

jQuery attr() fails to set attribute

I am trying to rotate an image via svg's transform. This is the code I have: This successfully rotates…
Majid Fouladpour
  • 26,043
  • 19
  • 66
  • 124
14
votes
4 answers

jQuery - How to select value by attribute name starts with

I want to select attribute value by giving attribute name (only starts with) For instance if we have html tag
I want to select the value from the attribute starts with data- Thanks in…
user3111581
  • 145
  • 1
  • 1
  • 4
13
votes
2 answers

Set switchStyle - get error resource not found - why?

I ran into a strange Problem: I am creating a style for an app and I set: @style/CustomSpinnerAppearance @style/CustomTextViewAppearance
KarlKarlsom
  • 5,839
  • 4
  • 27
  • 35
13
votes
2 answers

jQuery attr() change img src

I'm making some Rocket launching effect by jQuery. When I click on Rocket, it'll swap with another rocket image, and then launch up. When I click "Reset" link, Rocket must reset starting location and image must revert back. But there are two…
Gereltod
  • 1,866
  • 7
  • 22
  • 39
13
votes
7 answers

Using jQuery attr() to set “css”

I am reading the book "jQuery Pocket Reference", O’Reilly, 2011. On page 15 it says: 'For example, calling attr("css", {backgroundColor:"gray"}) is the same as calling css({backgroundColor:"gray"}).' But I cannot make the attr(“css”, { }) work. My…
user3026964
  • 175
  • 1
  • 3
  • 7
13
votes
5 answers

How to get the style value using attr

My HTML CODE HERE: I want to get the background-color value using jquery attr. What i tried is below: $("#bgcolor").mouseleave(function(){ var bodyColor =…
Dilini Wasana
  • 183
  • 1
  • 2
  • 11
12
votes
3 answers

TinyMCE and jQuery - attr() is returning an Object

I've solved this by using data() instead of attr(), but I'd still like to know if this is just me, and what's causing it: I'm using jQuery 1.7.1 and TinyMCE 3.5b3 (jQuery package). No other JS libraries. This code outputs "string", and the anchor…
Wintermute
  • 2,545
  • 3
  • 26
  • 40
12
votes
3 answers

How do I check for empty attr() in jquery?

I have a few divs that are created using PHP. The anchor within the div always has a HREF, even if it is blank. Basically, I am trying to detect if the HREF is blank. If it has content, do nothing, if it's blank, strip the text out, delete the…
Jared
  • 1,745
  • 6
  • 32
  • 55
11
votes
1 answer

Why does jQuery val() function not update attribute 'value'?

I came across with this issue way after I completed the website since I had to implement history in ajax based page (which requires to update certain places with html (which includes forms with simple text inputs - that's where the problem - they…
Andrius Naruševičius
  • 7,659
  • 6
  • 44
  • 72
11
votes
1 answer

Creating default style with custom attributes

So here's my problem: I've created a custom component which extends the Button This button has one attribute called testAttr.
Nick
  • 1,693
  • 1
  • 14
  • 24
10
votes
5 answers

Open all links in new tabs with jQuery

I have some links that are placed in my page dynamically via JSON and have no way to directly edit them. I want to force all links to open in new tabs, ala target="_blank" Thought this would work.. but sadly it isn't. Any ideas? …
technopeasant
  • 7,309
  • 26
  • 86
  • 146
10
votes
1 answer

delay() and fadeOut() don't delay attr() in the queue

what is wrong in this code? I'm trying to get this effect: fadeOut(500) and attr('class','myClass') delayed by 600 millisecs.. then delay(600) again, and fadeIn(500). The delays happen correctly but the attr() is not being delayed, it fires when…
Luca
  • 7,571
  • 5
  • 41
  • 56
1 2
3
79 80