Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

javascript - 单击时更改按钮文本(Change button text when onclick)

I've this line of code

(我有这行代码)

<?php 
$STRING .= '<a href="#" onclick="changeText(this)" class="btn btn-info btn-lg"></a>';
?>

<script>
function changeText(id) {
id.innerHTML = "Ooops!";
}
</script>

which works fine and the button text changes to Oooops

(可以正常工作,并且按钮文本更改为Oooops)

I want the button text to change to the output of

(我希望按钮文本更改为的输出)

 $data = get_user_meta( $authorID, 'cellno', true);

I change the value of

(我改变了)

id.innerHTML = "Ooops!";

to

(至)

id.innerHTML = "$data = get_user_meta( $authorID, 'cellno', true)";

or

(要么)

id.innerHTML = "$data";

but it doesn't work :(, what am I doing wrong?

(但它不起作用:(,我在做什么错?)

EDIT: this is the where I took the function of data

(编辑:这就是我接受数据功能的地方)

 $data = get_user_meta( $authorID, 'cellno', true);
        if(strlen($data) > 0){ 
        echo "<span><i class='fa fa-phone'></i> <a href='phone:".$data."' rel='nofollow' target='_blank'>Mobile</a> </span>"; 
        }

does it change a thing?

(它会改变事情吗?)

the $data is from another file :D

($ data来自另一个文件:D)

  ask by Ahmed Nabil translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
id.innerHTML = "<?php echo $data = get_user_meta( $authorID, 'cellno', true); ?>";

要么

id.innerHTML = "<?php echo $data; ?>";

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...