语言环境检测和翻译?

时间:2016-07-17 00:05:45

标签: javascript jquery html dreamweaver

我正在Dreamweaver上构建一个离线多页面移动应用程序,我正在努力使应用程序只检测某些<h1>并将它们转换为用户手机设置为的语言环境语言, 但是我不知道怎么做。下面,我希望将最高<h1>翻译为用户区域设置语言,同时将底部<h1>保留为英文。

// HTML

<h1 class="TopText" id="HouseT">Apartment</h1>
<img src"~"/>
<h1 class="BotText" id="HouseB">Apartment</h1>

1 个答案:

答案 0 :(得分:0)

使用jQuery,您可以编写一个匹配第一个h1元素的选择器,但不匹配第二个。例如:

'h1.TopText'(选择具有ToText类属性的h1元素)或'h1#HouseT'(选择具有HouseT作为id的h1元素)然后继续操作它的内容。

这是一个有效的例子:

$('h1.TopText').html('some other text');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<h1 class="TopText" id="HouseT">Apartment</h1>
<img src"http://placehold.it/100x100"/>
<h1 class="BotText" id="HouseB">Apartment</h1>

相关问题