[英]Replace javascript text with jquery or other in HTML code
i have my main page (index.php) with look as : 我的主页(index.php)如下所示:
<?php start_session();
... PHP CODE ...
?>
<html>
... HTML CODE ...
<script type="text/javascript">
var bscTexts =
{
signup: {
cropPicture: 'Crop your profile picture',
},
home: {
noFavorites: 'You haven´t added any profiles as favorites'
},
general: {
errorUploading: 'Error uploading, please try again',
successfulUploading: 'Votre photo a bien été obtenue',
chooseAnotherPicture: 'Choisir une autre photo',
loadingMore: 'Loading, please wait...'
},
notificationBubbles: {
/*InterestedInYou */ 1: {
Text: '[Name] has shown interest in you',
Url: "/match/interestedinme"
},
/*Match */ 2: {
Text: 'You and [Name] are now a match',
Url: "/match/matches"
},
/*WinkSent */ 3: {
Text: 'You have received a wink from [Name]',
Url: "/home/socialstream"
},
/*LovedPicture */ 4: {
Text: '[Name] loves one of your pictures',
Url: "/home/socialstream"
}
}
};
</script>
... OTHER HTML CODE ...
</html>
I would like to know if is possible to replace the text (string statement) with jquery or other (dom) 我想知道是否可以用jquery或其他(dom)替换文本(字符串语句)
for example : 例如 :
if i call alert(bscTexts.signup.cropPicture); 如果我打电话给alert(bscTexts.signup.cropPicture); the result is popup alert with "Crop your profile picture" 结果是带有“裁剪您的个人资料照片”的弹出警报
i need to know if is possible after the page is loaded with jquery, javascript or other to replace "Crop your profile picture" with french translation to obtain this : 我需要知道在页面加载了jquery,javascript或其他内容之后是否有可能用法语翻译替换“ Crop your profile picture”来获得此信息:
<script type="text/javascript">
var bscTexts =
{
signup: {
cropPicture: 'Redimensionnez votre photo',
}
</script>
This is for example so i need to change ALL strings. 例如,因此我需要更改所有字符串。
Thank you for your helping ! 谢谢您的帮助!
There is a function for in jquery for rewrite vars after document ready : 在jquery中有一个函数可以在文档准备好后重写var:
jQuery(function($){
... rewrite your vars...
})
If you will change all strings just assign the object again : 如果要更改所有字符串,只需再次分配对象:
bscTexts = { ... };
if you have just the strings replace each one: 如果您只有字符串,请替换每个字符串:
bscTexts.signup.cropPicture = 'new value';
.
.
bscTexts.notificationBubbles.Text = 'new value';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.