This question already has answers here:
How to select html nodes by ID with jquery when the id contains a dot?
(8 answers)
Closed 9 years ago.
My html code is as below.
<div id="chatbox_dipesh.parmar" class="chatbox">
//html markup which is validated
</div>
in above code dipesh.parmar div added dynamically.
And i am accessing it using following code.
$("#chatbox_"+chatboxtitle).show();
where chatboxtitle is dipesh.parmar but its not selecting div.
Does . is not a valid for ID.?
My jQuery is loaded and its not conflicting with other library and also wrapped it into $(function(){ }).
Thanks.
Escape the dot.
See this:
Direction
Related
This question already has answers here:
How to turn off html escape in Smarty
(2 answers)
Closed 2 years ago.
Good morning,
I have variable with HTML code. For example:
{assign var="url" value="<a href='google.com'>URL</a>" nocache}
The next step is display the content.
{$url}
The result is:
<a href='google.com'>URL</a>
How to display the URL which will be a working link?
Kind regards
The answer is to add nofilter parameters to variable:
{$url nofilter}
This question already has answers here:
Make an excerpt with php without cutt last word
(4 answers)
PHP Description Excerpt
(4 answers)
Closed 4 years ago.
I want to create a description of the post. This description is taken from the content of the post, which may include html tags but I want not to include the html tags like <html>, <script> and so on.
For example:
I have some content as follows:
<html>ajsdhasudhasidyuai</html>
and I want to get the first 2 characters and without the <html> tag, so the result should be
aj
How can I achieve that?
You can achieve this with PHP code:
$extract = substr( strip_tags($content), 0, 2);
This will:
Strip all HTML tags from your content string
Take the first 2 chars (substring) from the clean content
Return aj for your given example.
You may want to create a helper function or class to achieve this but this is your starting point.
See example here
This question already has answers here:
Get text between HTML tags [duplicate]
(3 answers)
Closed 6 years ago.
I need to get the Text value of a HTML a link dynamically stored in PHP variable like
$term = 'Meat';
so the result will be Meat only. can you please let me know how to do this? Thanks
You could strip all tags from the text using strip_tags
echo strip_tags($term);
echoes: Meat
Reference: http://php.net/manual/en/function.strip-tags.php
This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Closed 8 years ago.
I am trying pass this code for html but not work, load as text.
HTML:
<div id="captcha-wrap">
<p>
</p>
<!-- show the captcha result - fail/pass -->
<div id="captcha-status">
</div>
JS:
$("#captcha-wrap").append("<?php require_once('_control/showcaptcha.php'); ?>");
You can't append PHP like that. Have a look at using AJAX.
This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
DOMDocument for parsing HTML (instead of regex)
(2 answers)
Closed 9 years ago.
I want to get the text from a div in this page:
<html>
<head>Hello world!</head>
<body>
This is a test!<br>Hello man!<br>
<div class="special">
I want this text
</div>
</body>
</html>
I am using this code to get the content without any tags:
echo strip_tags(file_get_contents('http://website.com'));
However, I would like only to get the content from the
<div class="special">
from that page. Is that possible in PHP?
Use a HTML parser to parse the object you read using file_get_contents(). This question lists a bunch of parsers you could use