attr

jQuery .prop() returns undefined, while .attr() works as expected for data-*

可紊 提交于 2019-11-29 02:19:50
I am simply trying to get a couple of properties from two elements. Getting the property value from the input element works as expected. The problem is with getting the property data-detail property from the button element. It returns undefined when using .prop() , but works as expected when using .attr() . Can anyone explain this odd behaviour I am witnessing? HTML <div class="formRow"> <label for="firstName">First name</label> <div class="detailsControlBtns"> <button id="editFirstName" class="btn ctaBtn greenBtn editBtn">Edit</button> <button class="btn ctaBtn greenBtn saveBtn" data-detail=

jquery: get value of custom attribute

↘锁芯ラ 提交于 2019-11-29 00:53:56
html5 supports the placeholder attribute on input[type=text] elements, but I need to handle non-compliant browsers. I know there are a thousand plugins out there for placeholder but I'd like to create the 1001st. I am able to get a handle on the input[placeholder] element but trying to get the value of the placeholder attribute is returning undefined - $("input[placeholder]").attr("placeholder") . I'm using jquery 1.6.2. Here is the jsfiddle . I modified the code to work in a browser that is html5 compatible just for testing purposes. html <input type="text" name="email" size="10" placeholder=

jQuery attr('onclick')

自古美人都是妖i 提交于 2019-11-28 22:37:42
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 an onclick attribute on element which has id="next". If someone knows where is the solution please help! Felix Kling Do it the jQuery way (and fix the errors): $('#stop').click(function() { $('#next').click(stopMoving); // ^-- missing # }); // <-- missing ); If the element already has a click handler attached via the onclick attribute, you have to remove

Use declare styleable to set custom component input type

我们两清 提交于 2019-11-28 21:05:59
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 am successful at setting minLines, maxLines and textColor. How can I set inputtype to my component via xml. my attributes.xml <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="CET"> <attr name="MaxLines" format="integer"/> <attr name="MinLines" format="integer"/> <attr name="TextColor" format="color"/> <attr name="InputType

jQuery check if attr = value

牧云@^-^@ 提交于 2019-11-28 18:12:22
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 appreciated. Thanks, Just remove the .val(). Like: if ( $('html').attr('lang') == 'fr-FR' ) { // do this } else { // do that } jQuery's attr method returns the value of the attribute: The .attr() method gets the attribute value for only the first element in the matched set. To get the value for each element individually, use a looping construct such as jQuery's

Jquery - determining which link was clicked

◇◆丶佛笑我妖孽 提交于 2019-11-28 06:30:13
问题 I have several similar links that trigger different navigation divs to appear. I am trying to find a way in JQuery to determine which of the links was clicked and then trigger the appropriate open/close functions. The html is: <a href="" id="nav1">1</a> <a href="" id="nav2">2</a> <a href="" id="nav3">3</a> <div id="hidden1">nav links 1</div> <div id="hidden2">nav links 2</div> <div id="hidden3">nav links 3</div> Currently I use a simple toggle assigned to each pair, but would like to set it

Jquery - animate height toggle

感情迁移 提交于 2019-11-28 06:13:04
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, or is there a better way to do it? body html: <div id="topbar-show"></div> css: #topbar-show { width: 100%; height: 10px; background-color: #000; } #topbar-hide { width: 100%; height: 40px; background-color: #000; } javascript: $(document).ready(function(){ $("#topbar-show").click(function(){ $(this).animate({height:40},200).attr('id', 'topbar-hide'

How to find elements with 'value=x'?

只谈情不闲聊 提交于 2019-11-28 05:35:49
I need to remove element that have value="123" . I know that all elements with different values are located into #attached_docs , but I don't know how to select element with value="123" . $('#attached_docs').find ... .remove(); Can you help me? If the value is hardcoded in the source of the page using the value attribute then you can $('#attached_docs :input[value="123"]').remove(); If you want to target elements that have a value of 123 , which was set by the user or programmatically then use EDIT works both ways .. or $('#attached_docs :input').filter(function(){return this.value=='123'})

How does one add an attribute to a model?

雨燕双飞 提交于 2019-11-28 04:21:08
In rails I generate a model with two strings and would like to add more. How would I go about doing this? Active Record maps your tables columns to attributes in your model, so you don't need to tell rails that you need more, what you have to do is create more columns and rails is going to detect them, the attributes will be added automatically. You can add more columns to your table through migrations : rails generate migration AddNewColumnToMyTable column_name:column_type(string by default) Example: rails generate migration AddDataToPosts views:integer clicks:integer last_reviewed_at

Error:(9, 5) error: resource android:attr/dialogCornerRadius not found

五迷三道 提交于 2019-11-28 04:02:05
So I installed android studio 3.0.1 and as soon as it opened the gradle built and showed the following errors. I tried adding dependencies such as design and support but in vain. Could someone help me? Thank you in advance. It shows that some attributes such as dialogCornerRadius and fontVariation Settings not found. Sheharyar Ejaz This error occurs because of mismatched compileSdkVersion and library version. for example: compileSdkVersion 27 implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support:design:26.1.0' and also avoid to use + sign with library as