jQuery Hide div if price value is smaller than #2How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?Using jQuery to center a DIV on the screenChange the selected value of a drop-down list with jQueryCreating a div element in jQueryHow to replace innerHTML of a div using jQuery?Use jQuery to hide a DIV when the user clicks outside of itHow to apply !important using .css()?jQuery Hide div if value is smaller thanHow to hide div using jquery or java script if value is 0.00?How to hide div using jquery or java script?
What is a solution?
Why doesn't sea level show seasonality?
RPI3B+: What are the four components below the HDMI connector called?
How to tell someone I'd like to become friends without letting them think I'm romantically interested in them?
Was I subtly told to resign?
Keep milk (or milk alternative) for a day without a fridge
How can I calculate the sum of 2 random dice out of a 3d6 pool in AnyDice?
Is a request to book a business flight ticket for a graduate student an unreasonable one?
During copyediting, journal disagrees about spelling of paper's main topic
Is "I do not want you to go nowhere" a case of "DOUBLE-NEGATIVES" as claimed by Grammarly?
How to convert a file with several spaces into a tab-delimited file?
How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?
What's the point of having a RAID 1 configuration over incremental backups to a secondary drive?
How can a dictatorship government be beneficial to a dictator in a post-scarcity society?
Is there any word for "disobedience to God"?
Why does this quadratic expression have three zeroes?
Managing and organizing the massively increased number of classes after switching to SOLID?
How is angular momentum conserved for the orbiting body if the centripetal force disappears?
Are randomly-generated passwords starting with "a" less secure?
Cracking the Coding Interview — 1.5 One Away
Can fluent English speakers distinguish “steel”, “still” and “steal”?
Why does the U.S. tolerate foreign influence from Saudi Arabia and Israel on its domestic policies while not tolerating that from China or Russia?
Has anyone in space seen or photographed a simple laser pointer from Earth?
Single word for "refusing to move to next activity unless present one is completed."
jQuery Hide div if price value is smaller than #2
How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?Using jQuery to center a DIV on the screenChange the selected value of a drop-down list with jQueryCreating a div element in jQueryHow to replace innerHTML of a div using jQuery?Use jQuery to hide a DIV when the user clicks outside of itHow to apply !important using .css()?jQuery Hide div if value is smaller thanHow to hide div using jquery or java script if value is 0.00?How to hide div using jquery or java script?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have this div with small price and another div (discounted) with higher price
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
so when dicount div get higer price than above div then it should need to hide
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
If #1 price value smaller than #2
then i need to hide #2
jquery
add a comment |
I have this div with small price and another div (discounted) with higher price
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
so when dicount div get higer price than above div then it should need to hide
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
If #1 price value smaller than #2
then i need to hide #2
jquery
add a comment |
I have this div with small price and another div (discounted) with higher price
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
so when dicount div get higer price than above div then it should need to hide
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
If #1 price value smaller than #2
then i need to hide #2
jquery
I have this div with small price and another div (discounted) with higher price
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
so when dicount div get higer price than above div then it should need to hide
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
If #1 price value smaller than #2
then i need to hide #2
jquery
jquery
edited Mar 26 at 2:28
Aniket G
2,7591 gold badge6 silver badges31 bronze badges
2,7591 gold badge6 silver badges31 bronze badges
asked Mar 26 at 2:26
kriskris
228 bronze badges
228 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Use parseFloat()
to use math operations on the characters.
To get the first number, use the ^=
(starts-with) selector on the id
. The below means find the element with an ID that begins with... - and get the text inside that element:
let prx = $('[id^=sec_discounted_price]').text();
For the second number, you need to locate the first span via class, then traverse down to the second span:
let dsc = $('.ut-qty-discount-price>bdi>span').text();
Here is the working demo:
$('button').click(function()
let prx = $('[id^=sec_discounted_price]').text();
let dsc = $('.ut-qty-discount-price>bdi>span').text();
if (parseFloat(prx) < parseFloat(dsc) )
$('.ut-qty-discount-price').hide();
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
<button>Calculate</button>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348995%2fjquery-hide-div-if-price-value-is-smaller-than-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use parseFloat()
to use math operations on the characters.
To get the first number, use the ^=
(starts-with) selector on the id
. The below means find the element with an ID that begins with... - and get the text inside that element:
let prx = $('[id^=sec_discounted_price]').text();
For the second number, you need to locate the first span via class, then traverse down to the second span:
let dsc = $('.ut-qty-discount-price>bdi>span').text();
Here is the working demo:
$('button').click(function()
let prx = $('[id^=sec_discounted_price]').text();
let dsc = $('.ut-qty-discount-price>bdi>span').text();
if (parseFloat(prx) < parseFloat(dsc) )
$('.ut-qty-discount-price').hide();
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
<button>Calculate</button>
add a comment |
Use parseFloat()
to use math operations on the characters.
To get the first number, use the ^=
(starts-with) selector on the id
. The below means find the element with an ID that begins with... - and get the text inside that element:
let prx = $('[id^=sec_discounted_price]').text();
For the second number, you need to locate the first span via class, then traverse down to the second span:
let dsc = $('.ut-qty-discount-price>bdi>span').text();
Here is the working demo:
$('button').click(function()
let prx = $('[id^=sec_discounted_price]').text();
let dsc = $('.ut-qty-discount-price>bdi>span').text();
if (parseFloat(prx) < parseFloat(dsc) )
$('.ut-qty-discount-price').hide();
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
<button>Calculate</button>
add a comment |
Use parseFloat()
to use math operations on the characters.
To get the first number, use the ^=
(starts-with) selector on the id
. The below means find the element with an ID that begins with... - and get the text inside that element:
let prx = $('[id^=sec_discounted_price]').text();
For the second number, you need to locate the first span via class, then traverse down to the second span:
let dsc = $('.ut-qty-discount-price>bdi>span').text();
Here is the working demo:
$('button').click(function()
let prx = $('[id^=sec_discounted_price]').text();
let dsc = $('.ut-qty-discount-price>bdi>span').text();
if (parseFloat(prx) < parseFloat(dsc) )
$('.ut-qty-discount-price').hide();
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
<button>Calculate</button>
Use parseFloat()
to use math operations on the characters.
To get the first number, use the ^=
(starts-with) selector on the id
. The below means find the element with an ID that begins with... - and get the text inside that element:
let prx = $('[id^=sec_discounted_price]').text();
For the second number, you need to locate the first span via class, then traverse down to the second span:
let dsc = $('.ut-qty-discount-price>bdi>span').text();
Here is the working demo:
$('button').click(function()
let prx = $('[id^=sec_discounted_price]').text();
let dsc = $('.ut-qty-discount-price>bdi>span').text();
if (parseFloat(prx) < parseFloat(dsc) )
$('.ut-qty-discount-price').hide();
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
<button>Calculate</button>
$('button').click(function()
let prx = $('[id^=sec_discounted_price]').text();
let dsc = $('.ut-qty-discount-price>bdi>span').text();
if (parseFloat(prx) < parseFloat(dsc) )
$('.ut-qty-discount-price').hide();
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
<button>Calculate</button>
$('button').click(function()
let prx = $('[id^=sec_discounted_price]').text();
let dsc = $('.ut-qty-discount-price>bdi>span').text();
if (parseFloat(prx) < parseFloat(dsc) )
$('.ut-qty-discount-price').hide();
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<span class="ty-price" id="line_discounted_price_28797">
<bdi><span class="ty-price-num">£</span><span id="sec_discounted_price_28797" class="ty-price-num">0.99</span></bdi></span>
<div class="ut-qty-discount">
<div class="ut-qty-discount-price"><bdi>£<span>1.79</span></bdi></div>
</div>
<button>Calculate</button>
answered Mar 26 at 2:39
cssyphuscssyphus
24.2k10 gold badges64 silver badges83 bronze badges
24.2k10 gold badges64 silver badges83 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348995%2fjquery-hide-div-if-price-value-is-smaller-than-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown