Problem:
I need to create a shortcode that contains a value extracted from a strong tag.
When I echo "document.write(localStorage.getItem('getnum'));";
the code shows the value 85.
But when I return it (the following code), the shortcode [showpoints] shows no value.
Would you please let me know how to return the value?
Code I tried:
<?php
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
let getnum = $('div.elementor-widget-container p > strong').text();
JSON.parse(localStorage.getItem('getnum'));
});
</script>
<?php
function points_show_function() {
return "<script>document.write(localStorage.getItem('getnum'));</script>";
}
add_shortcode('showpoints', 'points_show_function');
Console:
No error
HTML (code came from a yith point & reward plugin):
<div class="elementor-element elementor-element-c1d0790 elementor-widget elementor-widget-text-editor" data-id="c1d0790" data-element_type="widget" id="pointsid" data-widget_type="text-editor.default">
<div class="elementor-widget-container">
<p>Your credit is <strong>85</strong> Points</p>
</div>
</div>