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.

1255 questions
21
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
  • 267
  • 1
  • 3
  • 11
21
votes
2 answers

How to add documentation to custom attributes?

I know how to create custom attributes for views, for example:
cottonBallPaws
  • 21,220
  • 37
  • 123
  • 171
20
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
  • 324
  • 1
  • 3
  • 10
18
votes
6 answers

How to erase all attributes?

I want to erase all attributes from data and applied this solution. However neither one_entry() (the original) nor my one_entry2() will work and I don't see why. one_entry2 <- function(x) { attr(x, "label") <- NULL attr(x, "labels") <-…
jay.sf
  • 60,139
  • 8
  • 53
  • 110
17
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
  • 215
  • 1
  • 4
  • 7
16
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
  • 165
  • 1
  • 1
  • 4
16
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
  • 9,452
  • 10
  • 51
  • 86
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
  • 29,356
  • 21
  • 76
  • 127
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,868
  • 4
  • 29
  • 36
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
  • 2,043
  • 8
  • 25
  • 39
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,973
  • 4
  • 32
  • 52
12
votes
1 answer

CSS attr() concatenation with url path

How can I concatenate the CSS attr() selector with static text in a url() field? The HTML I use:
//Example 2
//Example 3, 4, 5 For example: //image attribute contains the image…
TVA van Hesteren
  • 1,031
  • 3
  • 20
  • 47
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,795
  • 6
  • 32
  • 55
11
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,809
  • 31
  • 91
  • 149
11
votes
5 answers

How to remove class from all child elements

I have a html like:
---------------------- ---------------------- …
Shijin TR
  • 7,516
  • 10
  • 55
  • 122
1 2
3
83 84