attr

img thumbnail click replace div text value with thumbnail title

大憨熊 提交于 2019-12-10 19:18:21
问题 JSFIDDLE HERE If you look at the js fiddle you will find clicking the thumbail changes the image aswell as the .currentimgtitle text value but it changes all .currentimgtitle text values on the page when i only want to change the one relevant to it the jquery and html are below $(".imgcontainer").each(function() { var imgsrc = $(".minicontainer img:first-child", this).attr("src"); var imgtitle = $(".minicontainer img:first-child", this).attr("title"); $(this).append('<div class="presentouter"

Why does jQuery val() function not update attribute 'value'?

荒凉一梦 提交于 2019-12-09 03:31:05
问题 I came across with this issue way after I completed the website since I had to implement history in ajax based page (which requires to update certain places with html (which includes forms with simple text inputs - that's where the problem - they don't get their values assigned, because they have their values set by val() and not by attr() - lies)). Am I doomed to have to replace all javascript from $('#xxx').val('someValue'); to $('#xxx').attr('value', 'someValue'); or there is some hope to

Creating a new attribute with jQuery [duplicate]

…衆ロ難τιáo~ 提交于 2019-12-08 21:38:22
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: jQuery .attr retrieving custom attribute returns undefined I've got a weird problem, but I'm hoping I'm just doing something stupid. I'm trying to create a new attribute on an <img> element using jQuery, and this line: $(selector).attr('selected', 'no'); When I inspect the DOM in Chrome, I just see selected="selected", no matter what I set the value to. Just some extra info: I can't use just boolean values, as I

Set selected using jQuery

徘徊边缘 提交于 2019-12-08 06:22:22
问题 I'm trying to change the selected option within this list.. Its only working for some and not others? selectedVal will either be Kelly Green, Navy etc... var selectedVal = $(this).text(); $("#product-variants-option-0 option[text=" + selectedVal+"]").attr("selected","selected") ; This is the select list: <select class="single-option-selector" id="product-variants-option-0"> <option value="Gunmetal Heather">Gunmetal Heather</option> <option value="Kelly Green">Kelly Green</option> <option

Using jQuery each to replace image source

时光毁灭记忆、已成空白 提交于 2019-12-08 04:53:05
问题 I have the following issue. On load I want to use each to go through all the divs with the ".image" class, get the source of the image in that div and replace the source of the corresponding list item. Example below: useThis1 will replace the source of item1, useThis2 will replace the source of item2, so on and so forth. Any help on this would be much appreciated. <div class="image"><img src="useThis1"/></div> <div class="image"><img src="useThis2"/></div> <div class="image"><img src=

Unable to reach local host via terminal window

房东的猫 提交于 2019-12-08 03:54:19
问题 I am using Apache Maven in Java eclipse to Run Xacml code but when I am going to access local Host I am stuck at started jetty server and ended up with the given error... at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356) Caused by: org.eclipse.jetty.util.MultiException: Multiple exceptions at org.eclipse.jetty.annotations.AnnotationParser.parseJar (AnnotationParser.java:893) at org.eclipse.jetty.annotations.AnnotationParser.parse (AnnotationParser.java:851) at org

Get all ID of input box that contains a class

▼魔方 西西 提交于 2019-12-08 03:18:46
问题 How can i get the ID of an input box that contains a certain class value ex: <input id="first" class="failed" /> <input id="last" class="failed" /> <input id="city" class="failed" /> <input id="state" class="failed" /> I want to alert all the ID that contains the class failed after pushing a button or a command. 回答1: I want to alert all the ID that contains the class failed after pushing a button or a command. Use class selector to get elements with particular class. You can use each() to

Delete all classes after a certain class

和自甴很熟 提交于 2019-12-07 12:18:09
问题 I have a < div id="thisdiv" class="class1 class2 class3 class4 class5"> text < /div> I need to be able to delete all classes after class3 with jQuery. something like $('#thisdiv').removeClass(all after class3); OR $('#thisdiv').attr('class', all from class1 to class3); Please how can I do that? 回答1: You can try the following, but your classes might not be in the same order as they appear in the HTML source: $('#thisdiv').attr('class', function(i, v) { var classes = v.split(' '), position = $

Custom Attribute Error - Android Studio 1.2

最后都变了- 提交于 2019-12-07 02:39:38
问题 In my Android project I have a couple of custom components that use custom attributes. The attrs.xml file looks like this: <?xml version="1.0" encoding="utf-8"?> <resources > <declare-styleable name = "TextBox"> <attr name = "font" format = "string"/> </declare-styleable> <declare-styleable name = "ButtonBox"> <attr name = "font" format = "string"/> </declare-styleable> </resources> I am pulling in the attributes just fine in the custom component, but when I go to run the code I see the

Can you define your own HTML element attributes?

泪湿孤枕 提交于 2019-12-06 23:47:48
问题 I was wondering if you can define your own attributes in HTML. For example in HTML divs there's a range of attributes, such as style , title , class etc. Can you make up and add your own, while remaining syntactically correct? For example: <div class="example" test_item="20"></div> The need for this is with regards to Javascript and data. 回答1: With one exception — no. HTML uses the attributes and elements defined by the specification, and only those attributes and elements. That exception is