jQuery can only clone what is on the current page or what is loaded over AJAX, so setting something up on the backend and cloning it on the front is not possible. What you can do is create a string and print to the front as a Javascript variable or as a hidden div that you can then clone with jQuery. WordPress does this on the backend if you look near the top of any backend page. For example:
function tst() {
echo '<script type="text/javascript">var hello="hi";</script>';
}
add_action('wp_head','tst');
Related Posts:
- Most efficient way to add javascript file to specific post and/or pages?
- How to correctly add Javascript in functions.php
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Jquery ajax to custom php file: returning blank data
- jQuery functions only work on homepage
- How do I add a php statement to a jQuery string
- Looking for a better way to handle an ajax script that pulls in post data on click
- How can I loop into two different DIVS without repeating the DIVs
- Can’t use get_results() in ajax query
- How can one utilize a variable as a callback function name for add_settings_field
- Display notification only once
- Access/update database with jQuery
- Passing jQuery value using Ajax to a page template
- Using wp_localize_script to store the template url into a variable to use in JS
- How to get bool with `get_option()` when already registered setting with type `boolean`
- How to add a dynamic javascript snippet to the footer that requires jQuery
- Why can’t I use “%s” format value in the WordPress function checked?
- ajax_object is not defined when ajax calls the function
- Why is this Ajax not working?
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Ajax return code 400
- How to show a dynamic_sidebar if main content content’s height is > a set amount?
- combine Code 1 with Code 2
- wordpress count link clicks by ip address
- ajax, right way to do it and make it works?
- WordPress ajax doesn’t display object method on jQuery .change() function
- Menu jumping when calling it via PHP
- Setting value of session with Ajax not working
- Click a radio button must set textfield value
- Post repeating with infinite scroll
- Get URL Parameters from referer
- WordPress admin-ajax.php 400 bad request
- WordPress Ajax Call inserting data but success response false
- Ajax contact form return 0
- How can i display a jquery slide on front page
- AJAX – Returning Two JSON Objects with One PHP Function
- Unset session variable on page reload / setup but exclude AJAX
- Add Ajax Hooks and Call from Custom Template PHP
- WordPress Ajax Always returning 0
- Jquery window.send_to_editor function
- Theme not calling Jquery properly
- How to add drag and drop functionalities to a div inside option panel
- how to save checkbox data for custom setting?
- How to make jquery count down timer function manually editable
- My jQuery Ajax form submit is still refreshing page?
- jQuery accordion menu
- Removed jQuery script from header.php , any problems?
- Set cookie for visitor
- Execute Jquery when a specific page in my plugin is loading
- Covert WordPress Blogname into JQuery
- Hot to check if new posts have been published since page load and notify online users?
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Database entry removed on browser refresh, Ajax PHP jQuery
- how can i include post meta in search result
- How to send a php var to jQuery Ajax call with two different file
- WooCommerce Query Product Titles
- jquery & ajax getting data from php in wordpress . admin-ajax.php returns 400
- Settings API form – submit with AJAX
- How do I call a value from the datase using ajax
- Replace jQuery with PHP or CSS for Customized WordPress wp_nav_menu
- Dropdown Category form. Only show Sub-Categories
- Where to add my PHP codes for AJAX Jquery to work?
- Outputting post content to jQuery .html() string
- How to use wp_ajax_set_post_thumbnail?
- Implement jQuery Smart wizard
- How to reload a php script, using AJAX and jQuery
- Woocommerce – if selected attribute term equals
- WordPress Slick Slider + Magnific Popup
- Using wp_editor() when not logged stopped working
- How to call a WP Class inside my theme
- Show the subcategory name based on current product
- image on homepage disappeared due to change of permalink name
- Move Jquery.js to Footer
- getting the values of hidden inputs to use them in a php mysql query
- Custom theme admin-ajax.php 400 (Bad Request)
- How to call WordPress PHP file using external js file
- Creating Log-In Page for backend server
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Ajax not updating to database
- WordPress 404 when using AJAX to call php function
- how use php query in AJAX jquery
- jQuery doesn’t work in my php snippet
- Ajax Load more CPT via shortcode
- Submitting my form to the database and then redirecting to payment site
- WordPress Setting API – There is no field in options.php
- Querying posts based off a jquery datepicker
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- Pass the updated value of aid from form using ajax
- Combining fancybox with multiple thumbnail plugin
- Highlight posts currently being edited on multiple editor site?
- How to change links in the 3 main categories, on widget category, to a javascript function call
- best way to communicate between php and jquery/javascript
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- Add specific phrase after every product title including the discounted price? [closed]
- why my “recepie” category is not taken into account in my request
- AJAX: WordPress filters inside $html do not work as intended
- Adding Custom JQuery Menu Fresh Slide Out
- Why not showing all post by default in my jquery filter