Simple jQuery Selector Class Change

Developer
Size
1,802 Kb
Views
2,024

How do I make an simple jquery selector class change?

What is a simple jquery selector class change? How do you make a simple jquery selector class change? This script and codes were developed by James Zedd on 09 January 2023, Monday.

Simple jQuery Selector Class Change Previews

Simple jQuery Selector Class Change - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple jQuery Selector Class Change</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <p class="foo foo-over"> This item ships for free!
</p>
<p class="foo foo-under"> Orders $50 or over will Ship for free!
</p>
<select id="price_selector"> <option value="over-50">Over $50</option> <option value="under-50">Under $50</option>
</select> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Simple jQuery Selector Class Change - Script Codes CSS Codes

.show {color: blue;}
.hide {color: red;}

Simple jQuery Selector Class Change - Script Codes JS Codes

$('.foo-over').addClass('show');
$('.foo-under').addClass('hide');
$('#price_selector').change(function(){ if ($('#price_selector').val() == 'over-50') { $('.foo-over').removeClass('hide').addClass('show'); $('.foo-under').removeClass('show').addClass('hide'); } else { $('.foo-over').removeClass('show').addClass('hide'); $('.foo-under').removeClass('hide').addClass('show'); }
});
Simple jQuery Selector Class Change - Script Codes
Simple jQuery Selector Class Change - Script Codes
Home Page Home
Developer James Zedd
Username james_zedd
Uploaded January 09, 2023
Rating 3
Size 1,802 Kb
Views 2,024
Do you need developer help for Simple jQuery Selector Class Change?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

James Zedd (james_zedd) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!