admin管理员组

文章数量:1429648

I have this French string:

Veuillez indiquer vos spécialités

I want it like this in my JS Alert:

Veuillez indiquer vos spécialités

Here is my code:

$(function(){
    alert('Veuillez indiquer vos spécialités');
});

Fiddle here : /

I have this French string:

Veuillez indiquer vos spécialités

I want it like this in my JS Alert:

Veuillez indiquer vos spécialités

Here is my code:

$(function(){
    alert('Veuillez indiquer vos spécialités');
});

Fiddle here : http://jsfiddle/M6rLL/

Share Improve this question edited Nov 27, 2013 at 10:03 Martijn 16.2k4 gold badges38 silver badges72 bronze badges asked Nov 27, 2013 at 9:46 Hassan SardarHassan Sardar 4,52317 gold badges61 silver badges92 bronze badges 2
  • 2 alert('Veuillez indiquer vos sp\351cialit\351s'); – krasu Commented Nov 27, 2013 at 9:50
  • PHPJS's html_entity_decode – h2ooooooo Commented Nov 27, 2013 at 9:51
Add a ment  | 

1 Answer 1

Reset to default 6

Since you are using jQuery:

$(function(){
    var frenchy = 'Veuillez indiquer vos spécialités';
    alert(  $('<div />').html( frenchy ).text() );

    // If performance is an issue, you can change the dom creation of the div:
    // alert( $(document.createElement('div')).html( frenchy ).text() );
});

And the jsFiddle Demo. And this answer explains why the latter is faster :)

本文标签: jqueryConvert ampeacute to its orignal form in JavascriptStack Overflow