Expand my Community achievements bar.

SOLVED

How to change specific data of dialog box using js.

Avatar

Level 3

In my dialog I want to change specific content like in my dialog I have written "Search result for {{currentPage}}". Now I want to change only content of {{currentPage}} using js. How can that be done?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @ShagunMalik 

Using jquery you can do something like below:

 

<div class="something">Search result for {{currentPage}}</div>
var replaceString = $(".something").text();
var text = replaceString.replace("{{currentPage}}", "whatever text");
$(".something").text(text);

 

Thanks! 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Hi @ShagunMalik 

Using jquery you can do something like below:

 

<div class="something">Search result for {{currentPage}}</div>
var replaceString = $(".something").text();
var text = replaceString.replace("{{currentPage}}", "whatever text");
$(".something").text(text);

 

Thanks! 

Avatar

Community Advisor

@ShagunMalik Yes you can do using either Id or Class.

 

<div id="something">Search result for {{currentPage}}</div>

 

var replaceString = $("#something").text();
var text = replaceString.replace("{{currentPage}}", "whatever text");
$("#something").text(text);