Ad

How To Read The Value Printing Inside A Jsp (as A Custom HTML Tag) OnChange Event In JS

- 1 answer

I am using the following to read the image from local system and try converting the same into base64 using moxie.

<a id="file-picker" target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="javascript:;"></a>

Base 64 result is printing inside code

<code id="result"> Result is printing here</code> 

I need to access the result(Base 64 value) in Js:

 $("#file-picker").on('change',function(event){
var tmppath ;
tmppath = $("#code").val();

How do I read the base 64 value printed inside the in JS on change event?

Ad

Answer

You can get the internal data from <code></code> using .html()

$("#file-picker").on('click',function(event){

    var tmppath = $("#result").html();

}

And you should bind click event on anchors and not change event

Ad
source: stackoverflow.com
Ad