Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

wordpress - Display text from alt tag of from title tag on a button with CSS

How to display text from alt tag of from title tag on a button with CSS or with JavaScript? Something like this

document.getElementById("myBtn").value="MyNewValue";

But how do I get the ID's for this buttons?

The buttons are social login buttons and you can see them here:

Virtual Forms Framework login

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

You have to add some javascript code to achieve this. Check below Snippet:

$('.the_champ_login_ul li').each(function(index) {
  $('<span>' + $(this).find('i').attr('alt') + '</span>').insertAfter($(this).find('i ss'));
});
.theChampLogin {
  width: 100%;
  display: block;
}

.theChampFacebookBackground {
  background-color: #3C589A;
}

.theChampFacebookLoginSvg {
  background: url(//login.create.net/images/icons/user/facebook_30x30.png) left no-repeat;
}

.theChampTwitterLoginSvg {
  background: url(//login.create.net/images/icons/user/twitter-b_30x30.png) left no-repeat;
}

.theChampLoginSvg {
  height: 100%;
  width: 35px;
  display: inline-block;
}

.theChampLogin {
  padding: 0!important;
  margin: 2px;
  height: 35px;
  float: left;
  cursor: pointer;
  border: none;
}

ul.the_champ_login_ul li i span {
  font-style: normal;
  display: inline-block;
  color: #fff;
  line-height: normal;
  vertical-align: top;
  padding-top: 10px;
}

ul.the_champ_login_ul {
  list-style: none!important;
  padding-left: 0!important;
}

.theChampTwitterBackground {
  background-color: #55acee;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="the_champ_login_ul">
  <li>
    <i class="theChampLogin theChampFacebookBackground theChampFacebookLogin" alt="Login with Facebook" title="Login with Facebook" style="display: block;"><ss class="theChampLoginSvg theChampFacebookLoginSvg"></ss></i></li>
  <li>
    <i class="theChampLogin theChampTwitterBackground theChampFacebookLogin" alt="Login with Twitter" title="Login with Twitter" style="display: block;"><ss class="theChampLoginSvg theChampTwitterLoginSvg"></ss></i></li>
</ul>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...