Display jquery code in an ID

Asked

Viewed 21 times

0

Gallery I need help with my code, what I’m doing wrong?

onFinish: function () { <br><br> 
    console.log('registrationStoreId') 
    console.log(pmMVCHelpers.user.getProperty('registrationStoreId'));

    var registrationStoreId = $("#loja").text(


     if($('registrationStoreId').val() = "17"){
        .text(NA LOJA UM EM ATÉ <br> 05 DIAS ÚTEIS)

    } 

     else if ($('registrationStoreId').val() = "34"){
        .text(NA LOJA DOIS EM ATÉ <br> 05 DIAS ÚTEIS)

    }

    else ($('registrationStoreId').val() = " "){
        .text(EM ATÉ 15 DIAS ÚTEIS)
    } 
};
  • What’s wrong? You get an error?

  • Don’t put the if within the method .text.

  • You are wanting to send a text to div depending on the if?

1 answer

0


To add a code in the text format within an element, it is necessary to convert it to String or use Template String:

To use the Template String, just wrap the code with the grave accent `, for example:

$("#codigo").text(`if ($('registrationStoreId').val() = "17") {
    .text(NA LOJA UM EM ATÉ < br > 05 DIAS ÚTEIS)

  } else if ($('registrationStoreId').val() = "34") {
    .text(NA LOJA DOIS EM ATÉ < br > 05 DIAS ÚTEIS)

  } else($('registrationStoreId').val() = " ") {
    .text(EM ATÉ 15 DIAS ÚTEIS)
  }
}`);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<pre><code id="codigo"></code></pre>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.