Hello I am new with jQuery stuff so I need your support.
I am using Bootstrap Select script and I want to remove Price, when user select to drop-down.
If user select values Price, will be removed else add Price,
My Sample JSFiddle
you can use the title option like so: $(".sort_low_to_high").selectpicker({title:'Price'});
Demo: JS Fiddle
You are giving multiple attribute in <select> tag. This will make the selection as multiple, but sorting will either be high to low or low to high. So you should remove multiple attribute.
My Fiddle : http://jsfiddle.net/pvT8Q/53/
You have not given id's to give id and in your code.
after that you can remove it by $("#id").remove();
This will play nicely with the Bootstrap markup: http://jsfiddle.net/pvT8Q/54/
$('.bootstrap-select').on('click', function() {
$('.selectpicker').find('li').first().hide();
});
Related
I am experimenting with select2 by adding custom tags to it.
I do this with this code:
$(".js-example-basic-multiple")
.on("select2:selecting",
function() {
e.params.args.data.text = parentTarget + e.params.args.data.text;
});
I am using the multiple attribute BUT i am using the optgroup elemnt of the select list and it acts as a parentId container where only one element per container can be selected. This is solved but what i can not do is remove "MycustomTag" from previous selected option.
MycustomTag is either
Users
Or
Tank
And when selecting a new option i want to remove the Tank/Users tag on the previous selected option. In my debuging process i found that this is getting overriden in the change event but I can't figure out how to stopp it.
the code is pretty huge so I created a fiddle
How can I remove the tag that I am setting?
After some extensive detective work I found a very simple answer...
$(this).data().data.text = $(this).data().data.text.replace(parentTarget, "");
fiddle has been updated
I am trying to select a certain value in my dropdown via jquery..I tried this..
$("#membershiptype").val(1).selected;
it doesnt work..I am clearly over my head here as I am inexperience in jquery.
To select an option by index, you can do this :
$("#membershiptype").get(0).selectedIndex=1;
Demonstration
To select an option by value (the content of the option), you may use this :
$("#membershiptype").val('B');
Demonstration
You can assign the val() to the option value you want to be selected.
$('#membershiptype').val(valueToBeSelected);
Been trying to work this out for a little while now, no luck.
jQuery("#choosenCause option:selected").removeAttr("selected","selected");
jQuery('#choosenCause option[value="'+json.causeID+'"]').attr("selected",true);
I'm using the above, it adds selected="selected" to the right element, but does not change the selected element that the user sees.
Full JS here - http://inspire.simplyfundraising.co.uk/wp-content/themes/inspire/assets/js/promojs.js
To set the selected option of a select element, use val():
jQuery('#choosenCause').val(json.causeID);
in the first string you need to correct the code - jQuery("#choosenCause option:selected").removeAttr("selected");
the second string works fine as i see
I am new to JavaScript and jQuery, but have used HTML and CSS before. In any case, I appreciate the help. I have implemented the script discussed here http://net.tutsplus.com/tutorials/javascript-ajax/using-jquery-to-manipulate-and-filter-data/ for filtering data and the one discussed here http://www.dustindiaz.com/check-one-check-all-javascript/ for a check one to check all script. The problem is, when I filter the list of items and then use the check all box, it is checking even the JS items that are hidden from the user due to filtering. Does this make sense?
I have been trying to figure out how to edit the check all script so that only items with the "visible" class (as added to visible checkboxes with the filtering script) are checked with the checkAll button. The original script had:
var checks = document.getElementsByName('del[]');
I was trying to do something like this (it wasn't working, of course):
var visiblechecks = $('input:del[]:checked.visible');
among other things.
Thank you! Also, if you have a recommended resource, I would appreciate it.
var visiblechecks = $('input[name="del[]"]:checked:visible');
Your selector just needs a bit of refinement. Try:
$(".myCheckAllSelector").change(function () {
$("input[name='del[]']:visible").attr("checked", $(this).is(":checked"));
});
This should set the checked attribute of all currently visible checkboxes with the name del[] to the checked status of the check all box. You simply need to update the check all selector appropriately to target your master checkbox element.
You don't necessarily "need" to add a visible class as there is a :visible filter you can use to make that determination for you. However, just change your selector from input to input.visible if you still wish to use the class and remove the :visible filter..
Im wanting to collect the selected value of a select list, and insert the value into span tag. I am using the msDropdown jquery plugin which skins the select list.
The code below initiates the plugin, but how i would alter it to so that it outputs the value of the selected option to a span tag each time user selects an option?
I know the answer is simple, and I do have some rough skills with jquery, but my brain has buckled because ive been coding in PHP for the past week and am finding it hard to remember how to tackle this.
$(document).ready(function() {
$("#websites2").msDropDown({mainCSS:'dd2'});
})
All help is appreciated, cheers Lea
First add the change listener to your select and then initialize the msDropDown. This works for me on the demo at http://www.marghoobsuleman.com/jquery-image-dropdown.
$('#websites2').change(function() {
$('#id-span').html($('#websites2').val());
});
$("#websites2").msDropDown({mainCSS:'dd2'});