saxonycreative on "[Plugin: Bop Search Box Item Type For Nav Menus] Focus / blur feature"

ساخت وبلاگ

Hi saxonycreative,

There is really only one way to go about this, and that is to use javascript.

var searchNodes = document.getElementsByName('s'); //get all search fields
for(var i=0; i<searchNodes.length; i++){ //apply onfocus action to each one in tu searchNodes[i].addEventListener('focus', function(e){ e.target.value = ''; //delete value e.target.removeEventListener(e.type, arguments.callee); //only do it the first time });
}

Note: this should be done at least after the document ready event has been fired.

To add this to your theme, either add it to an already existing bespoke js file or create a new one and enqueue it in your functions.php.

If your theme is a third party one, you'll need to add this as a plugin to avoid the same issue of updates overwriting your changes. It can be just a short file naming the plugin and enqueuing the script - see here.

All that said, I would make sure this change is absolutely necessary before employing it. Many mode browsers come with a button to delete the existing value or highlight it by default on focus (hence making it easy to delete). However, immediately deleting on focus means that someone cannot easily edit their previous query and more often than not this is poor UX.

Hope this helps.

Cheers,
Joe

P.S. I am marking this topic as resolved as this is a theming issue and outside the remit of this plugin.

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 223 تاريخ : پنجشنبه 10 تير 1395 ساعت: 0:32