skip to Main Content

jQuery HTML Conditional Statement

What is a good way to ignore the tags/variables in a jQuery HTML method? For instance, if there was no value for company, it would not be included in the HTML. $('.modal-body').html(` <p><span style="font-weight:bold;">Name:</span> ${name}</p> <p><span style="font-weight:bold;">Company:</span> ${company}</p> <p><span style="font-weight:bold;">Job:</span>…

VIEW QUESTION

jQuery selector for data attribute array

Theres' this html code: <div class="wcpa_form_outer" data-attrrelated="[&quot;wcpa-select-1658734650073&quot;]"> for which i'm trying to append html to it. I have tried various approaches but none have worked. jQuery('.wcpa_form_outer[data-attrrelated="[&quot;wcpa-select-1658734650073&quot;]"]').append('some html here'); or jQuery('.wcpa_form_outer[data-attrrelated="[wcpa-select-1658734650073]"]').append('some html here'); or jQuery('.wcpa_form_outer').data('attrrelated').append('some html here'); any clues?

VIEW QUESTION

Printing value of custom attributes on multiple divs – Shopify

I am working on a Shopify store where there are multiple divs like below: <div class="options-selection__option-values" data-variant-option="" data-variant-option-index="0" data-variant-option-chosen-value="One"></div> <div class="options-selection__option-values" data-variant-option="" data-variant-option-index="0" data-variant-option-chosen-value="Two"> <div class="options-selection__option-values" data-variant-option="" data-variant-option-index="0" data-variant-option-chosen-value="Three"> <div class="options-selection__option-values" data-variant-option="" data-variant-option-index="0" data-variant-option-chosen-value="Four"> I want to get the value…

VIEW QUESTION

How to Select all buttons and alert their respective name when CLICKED in jQuery

$("button").on("click", function(){ var buttonClicked = $("button").attr("name"); alert("Button CLicked: " + buttonClicked); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <h1 class="titleClass">jQuery</h1> <div class="buttonClass"> <button name="up_button" id="upB" class="upDown"></button> <button name="left_button" id="leftB" class="leftRight"></button> <button name="right_button" id="rightB" class="leftRight"></button> <button name="down_button" id="downB" class="upDown"></button> </div> I want to display the…

VIEW QUESTION
Back To Top
Search