Fire event each time a DropDownList item is selected with jQuery

To expand Vincent Ramdhanie’s suggestion, take a look at doing something like this. Essentially, you end up with your own jQuery function that you can re-use elsewhere. Step 1: Create the jQuery Function (function($) { $.fn.selected = function(fn) { return this.each(function() { var clicknum = 0; $(this).click(function() { clicknum++; if (clicknum == 2) { clicknum … Read more

Codeigniter session bugging out with ajax calls

Try this <?php /** * ———————————————————————— * CI Session Class Extension for AJAX calls. * ———————————————————————— * * ====- Save as application/libraries/MY_Session.php -==== */ class MY_Session extends CI_Session { // ——————————————————————– /** * sess_update() * * Do not update an existing session on ajax or xajax calls * * @access public * @return void */ … Read more

Jquery – Remove only text content from a div

This should do the trick: $(‘#YourDivId’).contents().filter(function(){ return this.nodeType === 3; }).remove(); Or using an ES6 arrow function: $(‘#YourDivId’).contents().filter((_, el) => el.nodeType === 3).remove(); If you want to make your code more readable and you only need to support IE9+, you can use the node type constants. Personally, I’d also split the filter function out and … Read more

how to change a selections options based on another select option selected?

Here is an example of what you are trying to do => fiddle $(document).ready(function () { $(“#type”).change(function () { var val = $(this).val(); if (val == “item1”) { $(“#size”).html(“<option value=”test”>item1: test 1</option><option value=”test2″>item1: test 2</option>”); } else if (val == “item2”) { $(“#size”).html(“<option value=”test”>item2: test 1</option><option value=”test2″>item2: test 2</option>”); } else if (val == “item3”) … Read more

Installing jQuery?

Get jQuery up and running in a minute or less: Insert this into your HTML (most commonly in the head, but you can throw it before the end body tag too): <script type=”text/javascript” src=”http://code.jquery.com/jquery-latest.min.js”></script> Then place a script element after your jQuery one. This would alert ‘hello’ after the DOM is ready. <script>$(function() { alert(‘hello’) … Read more