Page 1 of 1

Change Caption Accordion with JS

Posted: 28 May 2018
by slashmaster
Hi,

it is possible, to change the Caption from an Accordion by Code (Displayform)?
Manuell i set the Title (or Caption?) to "old Caption" and the css-class named "cssAcc" and tried this code:

Code: Select all

$(".cssAcc").html($(".cssAcc").html().replace(/old Caption/,"new Caption"));
It displays the new Name, but the Accordion losts his functionality.

thx in advanced.

Re: Change Caption Accordion with JS

Posted: 28 May 2018
by Nikita Kurguzov
Dear slashmaster,
Please, use the following code, it should work:

Code: Select all

$('.ui-accordion h3:contains("old Caption")').text('new Caption');

Re: Change Caption Accordion with JS

Posted: 28 May 2018
by slashmaster
Dear Nikita,

thank u for ur fast Response. The good News: it works - i can expand or Close the Accordion. The Bad News: the Arrow (wich is showing expand/Close) is missing... Any ideas? :)

ty :)

Re: Change Caption Accordion with JS

Posted: 28 May 2018
by Nikita Kurguzov
Dear slashmaster,
Here, try this instead then:

Code: Select all

var newText = $('.ui-accordion h3:contains("old Caption")').html().replace("old Caption", "New Caption");
$('.ui-accordion h3:contains("old Caption")').html(newText);

Re: Change Caption Accordion with JS

Posted: 29 May 2018
by slashmaster
Good Morning Mr. Nikita :)
incredible, it works fantastic.
Thank u very very much! :)