[英]How to use same ID for multiple elements? - ArcText Wordpress Author Name JS
我正在使用[ArcText][1]
在wordpress的彎曲路徑上呈現作者姓名。 我是PHP和JS的初學者。
功能:
function get_meta($id){
echo <span id='example1'>".the_author_meta_r("display_name",$id)."</span>
}
ArcText腳本:
var $example1 = $('#example1').hide();
google.load('webfont','1');
google.setOnLoadCallback(function() {
WebFont.load({
google : {
families : ['Montserrat','Concert One']
},
fontactive : function(fontFamily, fontDescription) {
init();
},
fontinactive : function(fontFamily, fontDescription) {
init();
}
});
});
function init() {
$example1.show().arctext({radius: 150, dir: -1});
};
要顯示作者姓名,我使用:
<?php get_meta(1); ?><?php get_meta(2); ?><?php get_meta(3); ?>
問題在於,只有(1)個具有曲線的渲染,而另外兩個則沒有,因為其中三個具有相同的id,而一個元素可以具有一個id。
我可以使用課堂嗎? 由於我不知道用戶將使用<?php get_meta(); ?>
次數<?php get_meta(); ?>
<?php get_meta(); ?>
,這就是為什么我試圖避免使用多個ID來實現多個功能的原因。
function get_meta($class){
echo <span id='example1' class='useMultiTimes'>".the_author_meta_r("display_name",$class)."</span>
}
然后在Javascript中:
var $example1 = $('.useMultiTimes').hide();
或者,您可以執行以下操作:
var $example1 = $("span[class='useMultiTimes']").hide();
但這可能會隱藏具有相同類的所有元素嗎?
<?php get_meta('useMultiTimes'); ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.