if (count = 1) is always true, since it sets count equal to 1!. if (count == 1) will only be true if count is equal to 1. The two don't have to be of the same type. if (count === 1) will only be true if the two are equal and of the same type.
Count should be how many there are, not a string containing "Size: ...".
You should use the length property instead of .count() since it's slightly faster (this is according to jQuery).
You could wrap the whole thing into a self calling anonymous function, so that you don't pollute the global namespace.... unless you make use of these variables later on (obviously only in the case where you don't redirect the page).
I'm assuming the HTML is before the <script> tags.... if not, you need a doc ready: `$(function() { ... });
<!-- HTML up here ... -->
<script type="text/javascript">
(function() {
var count =($('.option').length);
// "count = 1" SETS COUNT EQUAL TO 1!!!!!
if (count === 1) {
// Why use each? We are redirecting to the first href.
$('.readmore a').each(function () {
var url = $(this).attr('href');
window.location.replace(url);
})
}
else {
alert("more than 1... specifically " + count);
}
})();
</script>
Finally, there is no reason to use .each() since you will redirect after the first .readmore a.... Maybe you should be checking how many .readmore as there are? At any rate this makes more sense to me:
<!-- HTML up here ... -->
<script type="text/javascript">
(function() {
var count =($('.option').length);
// "count = 1" SETS COUNT EQUAL TO 1!!!!!
if (count === 1) {
var url = $('.readmore a').first().attr('href');
window.location.replace(url);
}
else {
alert("more than 1... specifically " + count);
}
})();
</script>
jsFiddle example w 2
jsFiddle example w 1