Hello all, I'm wondering if someone could help me with some Jquery. I wonder if we can add the words "Start your search here" to the search box at the top of the OPAC main page, a message that gets replaced when patron starts to type. Thanks Nicole
Hi! You can try with something like this: http://jsfiddle.net/mPLFf/4/ Regards, alen Citiram Nicole Engard <nengard@gmail.com>:
Hello all,
I'm wondering if someone could help me with some Jquery. I wonder if we can add the words "Start your search here" to the search box at the top of the OPAC main page, a message that gets replaced when patron starts to type.
Thanks Nicole _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz http://lists.katipo.co.nz/mailman/listinfo/koha
Hi Nicole, try this (perhaps not work on IE9/8) $(document).ready(function(){ $("input[id=transl1]").attr("placeholder","Start your search here"); }); or $(document).ready(function(){ $("input[id=transl1]").attr("value","Start your search here"); $("input[id=transl1]").attr("onfocus","if (this.value=='Start your search here') this.value='';"); $("input[id=transl1]").attr("onblur","if (this.value=='') this.value='Start your search here';"); }); Regards, Bernardo -- Bernardo Gonzalez Kriegel bgkriegel@gmail.com On Thu, Aug 8, 2013 at 8:49 AM, Nicole Engard <nengard@gmail.com> wrote:
Hello all,
I'm wondering if someone could help me with some Jquery. I wonder if we can add the words "Start your search here" to the search box at the top of the OPAC main page, a message that gets replaced when patron starts to type.
Thanks Nicole _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz http://lists.katipo.co.nz/mailman/listinfo/koha
$("input[id=transl1]").attr("placeholder","Start your search here");
Is there an advantage to using "input[id=transl1]" over "#transl1" ? I've never seen a selector written that way when looking for something by id. A couple of efficiency points: If you have jQuery which makes multiple calls to the same element, you shouldn't query for that element more than once. Set a variable: var transl1 = $("#transl1"); ...and then re-use it: transl1.attr("value","Start your search here"); Second, there's no reason to add an onfocus attribute when you can add an event handler. And really we don't need to set a variable after all because we can simply chain everything: $(document).ready(function(){ $("#transl1").val("Start your search here") .on("focus",function(){ if(this.value == 'Start your search here'){ this.value = ''; } }) .on("blur",function(){ if(this.value==''){ this.value = 'Start your search here'; } }); }); -- Owen -- Web Developer Athens County Public Libraries http://www.myacpl.org
participants (4)
-
Alen Vodopijevec -
Bernardo Gonzalez Kriegel -
Nicole Engard -
Owen Leonard