jquery

Scroll to a section of the page when clicking on the navbar

拟墨画扇 提交于 2021-02-10 23:52:31
问题 I've been making my first website - a single page site with different sections containing content. I've created a nice looking navbar and have been scouring the internet to try and find a way to add functionality to it. Here is the markup of the navbar: <div class="nav"> <div class="container"> <div class="title"> <h3>Stewart Ehoff</h3> </div> <a href="#" class="logo-icon"> <img src="images/shield.svg"> </a> <ul class="menu"> <li><a href="#home">Home</a></li> <li><a href="#about">About</a><

Scroll to a section of the page when clicking on the navbar

。_饼干妹妹 提交于 2021-02-10 23:51:40
问题 I've been making my first website - a single page site with different sections containing content. I've created a nice looking navbar and have been scouring the internet to try and find a way to add functionality to it. Here is the markup of the navbar: <div class="nav"> <div class="container"> <div class="title"> <h3>Stewart Ehoff</h3> </div> <a href="#" class="logo-icon"> <img src="images/shield.svg"> </a> <ul class="menu"> <li><a href="#home">Home</a></li> <li><a href="#about">About</a><

Scroll to a section of the page when clicking on the navbar

ⅰ亾dé卋堺 提交于 2021-02-10 23:51:25
问题 I've been making my first website - a single page site with different sections containing content. I've created a nice looking navbar and have been scouring the internet to try and find a way to add functionality to it. Here is the markup of the navbar: <div class="nav"> <div class="container"> <div class="title"> <h3>Stewart Ehoff</h3> </div> <a href="#" class="logo-icon"> <img src="images/shield.svg"> </a> <ul class="menu"> <li><a href="#home">Home</a></li> <li><a href="#about">About</a><

jQuery multiple plus/minus Counter

妖精的绣舞 提交于 2021-02-10 23:45:15
问题 I want to have multiple plus/minus counters on my page. I have one working counter but want to make it generic so that multiple counters can have a different initial value and increase and decrease as clicked. $('.counter-btn').click(function(e) { e.preventDefault(); var $btn = $(this); $('.output').html(function(i, val) { val = val * 1 + $btn.data('inc'); return (val <= 0 ? '' : '+') + val; }); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

jQuery multiple plus/minus Counter

橙三吉。 提交于 2021-02-10 23:38:28
问题 I want to have multiple plus/minus counters on my page. I have one working counter but want to make it generic so that multiple counters can have a different initial value and increase and decrease as clicked. $('.counter-btn').click(function(e) { e.preventDefault(); var $btn = $(this); $('.output').html(function(i, val) { val = val * 1 + $btn.data('inc'); return (val <= 0 ? '' : '+') + val; }); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

jQuery multiple plus/minus Counter

守給你的承諾、 提交于 2021-02-10 23:37:31
问题 I want to have multiple plus/minus counters on my page. I have one working counter but want to make it generic so that multiple counters can have a different initial value and increase and decrease as clicked. $('.counter-btn').click(function(e) { e.preventDefault(); var $btn = $(this); $('.output').html(function(i, val) { val = val * 1 + $btn.data('inc'); return (val <= 0 ? '' : '+') + val; }); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Create unique buttons dynamically

我的梦境 提交于 2021-02-10 23:33:32
问题 I'm new to jQuery and am trying to create jQuery UI buttons dynamically and them to a list. I can create one list item but no more are appended after it. What am I doing wrong? $('#buttonList').append('<li><button>'+ username + '</button>') .button() .data('type', userType) .click(function(e) { alert($(this).data('type')); }) .append('<button>Edit</button></li>'); <div> <ul id="buttonList"> </ul> </div> This only creates one list item with two buttons (although the second button seems to be

Create unique buttons dynamically

好久不见. 提交于 2021-02-10 23:30:18
问题 I'm new to jQuery and am trying to create jQuery UI buttons dynamically and them to a list. I can create one list item but no more are appended after it. What am I doing wrong? $('#buttonList').append('<li><button>'+ username + '</button>') .button() .data('type', userType) .click(function(e) { alert($(this).data('type')); }) .append('<button>Edit</button></li>'); <div> <ul id="buttonList"> </ul> </div> This only creates one list item with two buttons (although the second button seems to be

Reinitialize jQuery after AJAX call

泪湿孤枕 提交于 2021-02-10 22:47:46
问题 I'm having a problem where after dynamically populating an element via AJAX, my jQuery functions aren't working on the new content. I have a list of files for example that is populated when hitting a "refresh" button. I want to display an alert with the filename when double clicking the item in the list. Each item has the "file" class. I'm using this code: $('.file').on('dblclick', function(event){ alert($(this).html()); }); This works for any elements that are there in the first place, but

Perform character count on different textarea id

半腔热情 提交于 2021-02-10 22:47:45
问题 I have several textareas, which the ids are different from each other and I do not want to replicate several jquery to perform on the textarea ids. How can I alter my jquery code to perform on the textareas with different ids? I have this jquery function now: var text_max = 2000; $('#count_message').html(text_max + ' characters left'); $('#ox_AcitivityForms_YouthActivity__remark').keyup(function() { var text_length = $('#ox_AcitivityForms_YouthActivity__remark').val().length; var text