Reputation: 1194
What function can replace a string with another Text, means
get text from .content
.
Like this <div class="content">text</div>
and then place it here: username : 'text'
Example #
Html: <div class="content">text</div>
Place text to username from .content
$(document).ready(function() {
$('#tweecool').tweecool({
//settings
username : 'I wan to Replace here',
limit : 5
});
});
After replace it should be like this:
$(document).ready(function() {
$('#tweecool').tweecool({
//settings
username : 'text',
limit : 5
});
});
So how to replace a string with a text from specific DIV
by jquery/JS.
Thanks!
Upvotes: 0
Views: 129
Reputation: 3429
Plz try This One:
StyleSheet:
<style type="text/css">
#overlay{
display:none;
background:red;
width:200px;
color:white;
text-align:center;
padding:10px;
border-radius:5px;
}
#overlay1{
display:none;
background:red;
color:white;
width:200px;
text-align:center;
padding:10px;
border-radius:5px;
}
</style>
Jquery function:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#overlay').fadeIn('fast').delay(1000).fadeOut('fast');
});
$(document).ready(function(){
$('#overlay1').fadeOut('fast').delay(2000).fadeIn('fast');
});
</script
Body
<div id ="overlay">hi</div>
<div id ="overlay1">hello</div>
Upvotes: 1
Reputation: 2801
For simple changing content. you could try like this.
$('div.content').html("username : 'text'");
But for your jQuery control like structure, you can customize it by using it's object like this.
var tObj = $("#tweecool").data("tweecool");
tObj.username = "text";
Upvotes: 1
Reputation: 388316
You can read the text contents use .text() and use it in the setting like
$(document).ready(function() {
$('#tweecool').tweecool({
//settings
username: $('.content').text(),
limit: 5
});
});
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://api.tweecool.com/js/tweecool.min.js"></script>
<div class="content">text</div>
<div id="tweecool"></div>
Upvotes: 1
Reputation: 1890
You can try with the text method
$("#tweecool").text(function () {
return $(this).text().replace("text", "hello world");
});
Upvotes: 1