Questions tagged [prop]

The prop() function was added in jQuery 1.6 library. It returns a property for the first element of the matched set.

The .prop() method gets the property value for only the first element in the matched set. It returns undefined for the value of a property that has not been set, or if the matched set has no elements. To get the value for each element individually, use a looping construct such as jQuery's .each() or .map() method.

The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.

293 questions
3
votes
1 answer

jQuerys prop() method returns wrong id

when I've an input with name="id" within a form, the prop('id') method returns the input element instead of the id as string: HTML
JS var $form = $('#testform'); var wrongId =…
ducci
  • 239
  • 2
  • 13
3
votes
1 answer

Way for child to inherit all properties from parent

I have three components that make up a fourth I want to call Search. {this.props.withFilter ? Filter Orders : null} However,…
ThomasReggi
  • 42,912
  • 63
  • 199
  • 343
3
votes
3 answers

Add html entity by name with jQuery prop()

I'd like to add an ellipsis to an input element's placeholder attribute with jQuery prop() but instead of the intended … I get literal string …. How can I add html entities by name with jQuery prop()? $(document).ready(function(){ …
billynoah
  • 17,021
  • 9
  • 67
  • 90
3
votes
2 answers

Add readonly to input fields in jQuery

I have problems adding readonly to some input fields. I have this code in the $(document).ready(function() { $('#powermail_field_ordreid').prop('readonly', true); $('#powermail_field_destination').prop('readonly', true); }); And then…
Thomas Bøg Petersen
  • 1,157
  • 2
  • 22
  • 57
3
votes
2 answers

jquery property disabled and input value form submit

What I wanna ask is, I have a check box called full screen and when I checked it the two input fields which are width and height should be disabled and the values of it set to null. I do it well with j query but when I submit the form with full…
canpoint
  • 595
  • 2
  • 6
  • 18
3
votes
3 answers

Getting prop('tagName') problems in jQuery

Having a bit of trouble with some strange setups I encountered while working on a bookmarklet for work purposes. I need it to be able to find all the video embeds on a page and process the information to generate JSON code to be inserted in our…
Dadan Perez
  • 31
  • 1
  • 4
3
votes
3 answers

jQuery live and prop and change

I need to fire an event when the 'checked' state of any one of several checkboxes is changed, and to do this not by listening for the click. Why? It looks like this: BUILD YOUR SUNDAE! All Flavors [] Chocolate [ ] Vanilla [ ]…
Tim
  • 8,256
  • 29
  • 96
  • 168
3
votes
3 answers

jQuery cannot get custom attributes on UL elements

I am currently focussing the following issue with jQuery 1.8.2. Custom attributes are working fine for e.g. input fields: $("#test").prop("required") true $("#test").get(0).required true But not with UL…
Peter
  • 41
  • 5
3
votes
1 answer

Simple Crossbrowser textarea expander

My previously simple textarea expander is now causing problems. $(document).on('keyup', 'textarea',function(){ $(this).height($(this).prop('scrollHeight')); }); Works fine on Firefox but on webkit browsers keeps increasing the text-area…
RIK
  • 17,723
  • 34
  • 107
  • 185
3
votes
1 answer

Option Prop Changing Default Selected Value - Jquery

So I have a selection list, and if the default value hasn't been changed from --- then return to the form false. Pretty much for validation purposes so we know they picked a title. The problem is that for some reason prop() is changing the default…
Howdy_McGee
  • 9,729
  • 25
  • 98
  • 172
2
votes
2 answers

JQuery disabling button

I build a quick pagination from scratch it kind of works, but for the past half hour I've been trying to get the next and/or previous button to disable at the last page like this: (this one is for the next button) if (currentPage.is(':last-child'))…
user1053263
  • 712
  • 2
  • 14
  • 33
2
votes
1 answer

How to pass one entry from a list as prop in Vue

Lets say I have the following list in data: data: { todos: [ { id: 1, title: "Learn Python" }, { id: 2, title: "Learn JS" }, { id: 3, title: "Create WebApp" } ] } Now I want to pass only the entry with id of 2 to the…
Alex T
  • 2,590
  • 4
  • 30
  • 60
2
votes
1 answer

Is prop method by jQuery suppose to be supported by IE

I couldn't find any reference in any documentation to the support of jQuery method by the different browsers. When I run the following code: var c = $("#textValue"); c.attr("style", "background-color: yellow"); c.prop("style", "background-color:…
shahar eldad
  • 813
  • 1
  • 10
  • 28
2
votes
2 answers

Prop shows in Dev tools but shows undefined when used

I'm passing a simple ID down to a child component but have an undefined console log error and cannot use the prop I pass the prop here to the child Which is then…
GrahamMorbyDev
  • 373
  • 1
  • 4
  • 19
2
votes
1 answer

Vue.js - prop sync not instant

Using vue.js to sync a prop between parent and child. The problem is sync uses events and every time I change the value I have to wait for $nextTick before the value updates. This is not ideal because I do not want to put $nextTick every time I…
koga73
  • 712
  • 6
  • 13
1 2
3
19 20