Put this markup where you would like to before footer. you can put this markup in page editor text mode too. But doing so will remain in that page alone. so place it in template files.
Search: <input type="text" id="fname" >
<a id="sear" href="" target="_blank">Search</a>
write a function and hook it to wp_footer
, place the code in funcitons.php.
function output_custom_script(){
?>
<script>
document.getElementById('fname').addEventListener('keyup', function() {
var x = document.getElementById("fname").value;
var url = "https://www.google.co.in/search?q=all+"+x+"&biw=1366&bih=643&source=lnms&tbm=isch";
document.getElementById("sear").href=url;
}, false);
</script>
<?php
}
add_action('wp_footer','output_custom_script');
Check this Js Fiddle
Related Posts:
- What’s the difference between “{}” and “[]” while declaring a JavaScript array?
- How do you check that a number is NaN in JavaScript?
- JQuery – $ is not defined
- Client on Node.js: Uncaught ReferenceError: require is not defined
- How can a Discord bot create a hyperlink in a Discord message in an embed or in general?
- Getting a UnhandledPromiseRejectionWarning when testing using mocha/chai
- Error: Can’t set headers after they are sent to the client
- Express error – TypeError: Router.use() requires middleware function but got a Object
- How can I get the data-id attribute?
- document.getElementById vs jQuery $()
- How to import jquery using ES6 syntax?
- How to filter an array/object by checking multiple values
- Does JavaScript pass by reference? [duplicate]
- How to resolve the C:\fakepath?
- React this.setState is not a function
- AngularJS- Login and Authentication in each route and controller
- Check if a variable is a string in JavaScript
- How to pass props to {this.props.children}
- Adding options to select with javascript
- MRAID file reference
- How to format numbers?
- Does parseDouble exist in JavaScript?
- What does !1 and !0 mean in Javascript?
- What is the most efficient way to deep clone an object in JavaScript?
- RegExp in TypeScript
- How to use searchFile and searchFolder at the same time correctly? – App Script
- node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON]
- Delete first character of a string in Javascript
- keycode 13 is for which key
- SyntaxError: ‘import’ and ‘export’ may appear only with ‘sourceType: module’ – Gulp
- Get the value of checked checkbox?
- Equivalent of jQuery .hide() to set visibility: hidden
- How can I get the last character in a string?
- Create table using Javascript
- Parse an HTML string with JS
- JS file gets a net::ERR_ABORTED 404 (Not Found)
- Shortest way to print current year in a website
- push object into array
- module.exports “Module is not defined”
- Why doesn’t JavaScript support multithreading?
- plain count up timer in javascript
- Uncaught TypeError: Cannot read property ‘name’ of undefined
- How to calculate date difference in JavaScript?
- How to add an object to an array
- Finding the average of an array using JS
- Is it possible to simulate key press events programmatically?
- Vue template or render function not defined yet I am using neither?
- Cannot read property ‘length’ of null (javascript)
- Caesar Cipher in Javascript
- Can’t perform a React state update on an unmounted component
- How to simulate a click with JavaScript?
- Return array from function
- Why define an anonymous function and pass it jQuery as the argument?
- Error parsing XHTML: The content of elements must consist of well-formed character data or markup
- How to scroll an HTML page to a given anchor
- Javascript call() & apply() vs bind()?
- “google is not defined” when using Google Maps V3 in Firefox remotely
- how to call a onclick function in tag?
- How to check if the URL contains a given string?
- Check if url contains string with JQuery
- what is the best way to check variable type in javascript
- JavaScript Array Push key value
- stopPropagation vs. stopImmediatePropagation
- typescript – cloning object
- Register and enqueue conditional (browser-specific) javascript files?
- How to replace regular jquery calls with CDN calls from Google?
- Editing Source Code in WordPress
- wp_enqueue_script isn’t connecting my custom js file
- How/Where is editor.min.js Added to the wp-admin Post Page?
- Why is this gutenberg custom format button only available from the toolbar as a dropdown?
- Should a WordPress plugin polyfill the global JS environment?
- Close TinyMCE plugin window on click away
- Running JS after theme customizer finished initialization
- Script Localization doesn’t work
- Help display image in single post using javascript zoom image..?
- How to conditionally show/hide controls & sections in WordPress customizer?
- Uncaught TypeError [closed]
- Checks when fetching data from multiple REST API endpoints in Gutenberg
- How to get the title of the item that is clicked on
- Correct way to include extra styles & script files?
- How can I allow HTML in Gutenberg UI elements help text?
- UnitControl – Block has encountered an error
- Building a Featured Gallery component for Gutenberg
- Should I manually resolve WP Core File security issues or await a subsequent WP release?
- Retrieving data about comments and likes
- Linking wp_enqueue can’t find the javascript file (adds “?ver=x.x.x” to the src)
- Uncaught TypeError: switchEditors.switchto is not a function
- Check if user can in javascript
- My code will not execute in wordpress, even though I’ve been told the code is fine
- Rest API and how to deal with it in server side
- Is it possible to override only a part of another plugin’s / theme’s js (asset) file?
- Gutenberg – dynamically created element: how to set onChange?
- JSX SVG Icon with WordPress
- How do I integrate a codepen?
- Can I just insert JavaScript by using ?
- Gutenberg Edit Block Inspector Controls and save
- JavaScript and Google PageSpeed + wp_enqueue_script
- How to adjust the selector used in JS to target only the one that was clicked on?
- How to remove js using theme, which was added by plugin in WordPress site?
- WordPress REST API response is empty in browser and script, but not in Postman