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
52
votes
2 answers

jQuery check if attr = value

I seem to be having trouble with my code. I need to say: if ( $('html').attr('lang').val() == 'fr-FR' ) { // do this } else { // do that } When I check the console, I just get an error telling me this isn't a function. Help would be…
beefchimi
  • 1,308
  • 2
  • 17
  • 34
49
votes
9 answers

Conditionally make input field readonly in Angular 2 or 4: Advice + Best/which way to do it

I was attempting to answer someone elses question. And in doing so realised there was quite a bit of uncertainty in my mind about a few things. I'm hoping someone can provide feedback on the numbered points 1..4: Task: Conditionally make input field…
JGFMK
  • 8,425
  • 4
  • 58
  • 92
46
votes
9 answers

Jquery - animate height toggle

I have a 10px bar along the top of the screen that, when clicked, I want it to animate to a height of 40px and then if clicked again, animate back down to 10px. I tried changing the id of the div, but it isn't working. How could I get this to work,…
We're All Scholars
  • 581
  • 2
  • 5
  • 7
44
votes
4 answers

How does one add an attribute to a model?

In rails I generate a model with two strings and would like to add more. How would I go about doing this?
jsttn
  • 1,495
  • 3
  • 16
  • 21
39
votes
4 answers

Use declare styleable to set custom component input type

I have a CompositeComponent (EditText+ImageButton) When clicking on button the edittext content will be cleared. It is working fine. My problem is setting attributes to my component. I am using declare-styleable to set attributes to my component. I…
Mahendran
  • 2,719
  • 5
  • 28
  • 50
38
votes
2 answers

Get value of custom attribute

I have two radio buttons. I would like to be able to get the value of the custom attribute "xmlvalue" of the checked radio button. I have tried with the following script: var userType = $("input[name=ctrl_CustomerType]:checked",…
Meek
  • 3,086
  • 9
  • 38
  • 64
37
votes
4 answers

jQuery attr('onclick')

I'am trying to change "onclick" attribute in jQuery but it doesn't change, here is my code: $('#stop').click(function() { $('next').attr('onclick','stopMoving()'); } I have an element with id="stop" and when user clicks on it I want to change…
Shalva Kakauridze
  • 1,225
  • 4
  • 12
  • 23
33
votes
7 answers

How do I set an attr_accessor for a dynamic instance variable?

I dynamically created an instance variable within my class: class Mine attr_accessor :some_var def intialize @some_var = true end def my_number num self.instance_variable_set "@my_#{num}", num end end How do I make @my_#{num}…
eywu
  • 2,654
  • 1
  • 22
  • 24
33
votes
6 answers

jQuery get the name of a select option

I have a dropdown list with several option, each option has a name attribute. When I select an option, a different list of checkboxes needs to appear - when another options is selected, that checkbox list should disappear and another one be…
Sam Skirrow
  • 3,647
  • 15
  • 54
  • 101
32
votes
1 answer

Should href be set with prop() or attr()?

If I want to change the href of a link dynamically, should I do so using prop() or attr()?
Francisc
  • 77,430
  • 63
  • 180
  • 276
28
votes
4 answers

Why jQuery 1.9+ attr() method not deprecated?

Can I, a jQuery1.9+ software developer, "deprecate" the use of the attr() method in my day-by-day work? As showed in many questions, .prop() vs .attr() (main) jQuery attr vs. prop, there are a list of props? jQuery attr vs prop? Migrating jQuery…
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
25
votes
4 answers

Does the attr() in jQuery force lowercase?

I'm trying to manipulate the svg 'viewBox' attribute which looks something like this: ... Using $("svg").attr("viewBox","..."); However, this creates a new attribute in the element called…
Ben Zuill-Smith
  • 3,504
  • 3
  • 25
  • 44
24
votes
6 answers

Get href attribute on jQuery

I have some table rows
BILL
  • 4,711
  • 10
  • 57
  • 96
22
votes
1 answer

Using attribute to modify a drawable element color

I try to make a custom Drawable by using attribute but I have an inflating error 01-21 11:01:06.171: E/AndroidRuntime(13695): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/action_bar_background.xml from drawable…
Ahmet
  • 271
  • 2
  • 8
22
votes
5 answers

JQuery - File attributes

Trying to access file attributes from an input field after a file is selected. Tried this but get the error 'file not defined' var file = $("#uploadedfile").prop("files")[0]; var fileName = file.fileName; var fileSize =…
JimmyJammed
  • 9,598
  • 19
  • 79
  • 146
1
2
3
83 84