custom-data-attribute

Creating empty data-attributes in Thymeleaf

谁说胖子不能爱 提交于 2019-12-14 03:57:57
问题 I'm attempting to create an element in Thymeleaf 3.0.3 (Spring 4.3.7) with a custom data-attribute: <input th:attr="data-customAttr=${item.getMyAttr()}" /> If the result of item.getMyAttr() was 'someVal', then the rendered HTML comes out to be: <input data-customAttr='someVal' /> However, if the result of item.getMyAttr() is an empty string, the custom attribute is thrown out by Thymeleaf altogether. The rendered HTML looks like: <input /> I need to know whether the custom attribute was

jQuery update initial price on click on checkbox that has data-price attribute

北慕城南 提交于 2019-12-14 03:18:44
问题 I want to update Initial Price when click on checkbox that has data-price value, i try to done it but no luck so far, so it would be highly appreciable if you advise me where I'm wrong about it. So here is the code; http://jsfiddle.net/2M4Gr/1/ HTML Markup: <div class="price">$ <span>10.00</span></div> <hr /> <form> <label><input type="checkbox" name="Side Order" value="Side Order 1" />Side Order 1</label> <label><input type="checkbox" name="Side Order" value="Side Order 2" />Side Order 2<

Foundation <nav data-topbar> disallows writing a <section> into <div>

Deadly 提交于 2019-12-13 19:23:05
问题 Is this behaviour expected, or a bug? When using Zurb Foundation 5's top-bar component, the rendered HTML is doesn't allow me to put a «section» tag inside of a «div». I have troubleshooted enough to know that this only occurs when you add the data-topbar attribute to the «nav». I am able to add a «ul» element in the «div» and have it render properly. However, the «section class="tob-bar-section"» is fighting me. Markup written to file: <nav data-topbar="topbar"> <div> <section></section> <

jquery retrieve relatedTarget.data('url') value

和自甴很熟 提交于 2019-12-13 14:05:59
问题 I need to retrieve the value of data-url attribute from event.relatedTarget I tried in many ways: e.relatedTarget.data('url') e.relatedTarget.attr('url') e.relatedTarget.prop('url') but it always return an error.. but the value is there: how can I retrieve it? thanks! Joe 回答1: Seeing as you're directly accessing the event object itself, jQuery's attr() and prop() methods will not work here as this isn't a jQuery object. You'll notice that there is no data key on the event object as well,

Using “data-*” attributes to replace the “id” attributes in HTML tags for CSS-Selecting Purpose

你离开我真会死。 提交于 2019-12-13 10:22:08
问题 Is it a good idea to use "data-" attributes to replace the "id" attributes in elements(tags) for css-selection purposes and then use those "data-*" attributes in automation testing scripts? 回答1: No. CSS selection and DOM-tree selection on id is much faster than selection any other attribute. Data-attribute select might be less efficient than selection on other attributes in somebrowsers. The exception might be if you are abusing id attributes: storing something that is not just an identifier

How to select elements with jQuery that have a certain value in a data attribute array

你。 提交于 2019-12-13 08:47:57
问题 is there a way in jQuery to select elements that have a certain value in a data attribute array? Consider this snippet of html: <li id="person1" data-city="Boston, New York, San Fransisco"> Person name 1 </li> <li id="person1" data-city="Los Angeles, New York, Washington"> Person name 2 </li> What is the best way in jQuery to select all persons with "New York" in the data-city attribute? 回答1: even though i don't see your html, it should be: $('[data-city*="New York"]') 来源: https:/

fetch the value of data-attribute based on active class

亡梦爱人 提交于 2019-12-13 02:57:54
问题 i want to fetch the value of data-attribute data-itemtype based on ul > li class = "activeTab" here is my code. <ul class="tabs"> <li data-itemtype="1" class="activeTab"><a href="#tab1">Published</a></li> <li data-itemtype="0" class=""><a href="#tab2">Unpublished</a></li> </ul> if class="activeTab" is in first <li> element then fetch the data attribute of first li element i.e 1 in this case and hence same applies for the second or any number of li elements. i tried this var itemType = $('ul

set div data attribute using a code behind value in an aspx page

陌路散爱 提交于 2019-12-13 02:19:32
问题 On an .aspx page I need to set the data-attribute on a addthis div. The value is an URL that is calculated in the code behind. <div class="addthis_sharing_toolbox" data-url="CodeBehindValue"></div> Is there a way to do this? 回答1: You have a couple options. Using a property <div class="addthis_sharing_toolbox" data-url="<%= PropertyFromCodeBehind %>"></div> Using a method <div class="addthis_sharing_toolbox" data-url="<%= MethodFromCodeBehind() %>"></div> 回答2: If you choose your div to run at

jQuery select data attributes with common keyword

我只是一个虾纸丫 提交于 2019-12-12 10:39:12
问题 I have two elements with the following setup: <span data-placeholder-class="test-class"></span> <span data-placeholder-template="/some/template.hbs"></span> I'm using underscore to loop over any elements containing either of these attributes and then performing relevant actions if they do. Currently this is done like so _.each($('[data-placeholder-class], [data-placeholder-template]'), function cb(element) { // code goes here }) Rather than have to define each data attribute to loop over I

multiple responsive owl carousel

对着背影说爱祢 提交于 2019-12-12 05:09:49
问题 i need to create multiple responsive owl carousel in some page, i need to works with Data Attributes. I work like this but i cant do responsive my carousel, jQuery var $carousel = $('.data-carousel[data-carousel]'); if ($carousel.length) { $carousel.each(function() { $(this).owlCarousel($(this).data('carousel')); }); } HTML <div class="owl-carousel data-carousel" data-carousel='{"margin": 10, "items": 4, "center": "true", "loop": true}'> <div class="item"><h1>1</h1></div> <div class="item">