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.

347 questions
4
votes
1 answer

Using jQuery's .prop method to set a property to a function

I am trying to assign a function to a property on bunch of elements using .prop() $('.whatever').prop({MyProp:MyFunc}); Looking closely at the documentation for this function it seems there is a special behaviour where the value is a function and…
DJL
  • 2,060
  • 3
  • 20
  • 39
3
votes
3 answers

TS2322: Type '{ text: string; }' is not assignable to type 'string'. while passing prop

I am trying to pass a prop of type string to a functional component defined in the same file and it is throwing the error: TS2322: Type '{ text: string; }' is not assignable to type 'string'. I have been trying different syntaxes, but the error…
eh1412
  • 43
  • 1
  • 2
  • 8
3
votes
1 answer

Django, Vue - How to pass prop from Django to Vue

Background Hello All, trying to build a 'retrospective app' using Django & VUE. I have already created login, and dashboard which displays list of 'boards' created by logged in user. A board is a table of topics anyone with link can add and log-in…
3
votes
2 answers

Unsure what type my prop is in react native typescript

I am trying to implement typescript into my project and I am having issues giving prop types to my swipe prop. They are both the correct type but when giving this type I get an error on line 72: style={[styles.container, isFirst &&…
Oliver Darby
  • 454
  • 1
  • 6
  • 15
3
votes
1 answer

Passing PHP variable as prop to Vue tab component

I'm trying to pass the PHP variable $avail as a prop to my Vue component ComponentHome. Below is a simplified version of my code. On my page, the "avail" variable seems to be undefined, as the space after "Availability:" is blank. I have tried using…
Agirl
  • 45
  • 2
  • 6
3
votes
0 answers

.attr() or .prop() or replaceWith Not Affecting href in iOS?

I am trying to figure out why the iOS Safari browser won't apply a href alteration, like it does on a desktop browser. So far, I have tried .attr() and .prop(), but neither one seems to apply the URL adjustment. To be more descriptive, I am trying…
nrweb
  • 211
  • 3
  • 15
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
  • 351
  • 1
  • 4
  • 15
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
  • 55,053
  • 85
  • 237
  • 424
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(){ …
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 BP
  • 1,187
  • 3
  • 26
  • 62
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
  • 817
  • 2
  • 9
  • 19
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,669
  • 31
  • 105
  • 183
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…
Walrus
  • 19,801
  • 35
  • 121
  • 199
1 2
3
23 24